File Coverage

lib/WSDL/XML/Generator.pm
Criterion Covered Total %
statement 16 18 88.8
branch n/a
condition n/a
subroutine 6 6 100.0
pod n/a
total 22 24 91.6


line stmt bran cond sub pod time code
1             package WSDL::XML::Generator;
2            
3 1     1   59081 use 5.006;
  1         4  
  1         46  
4 1     1   6 use strict;
  1         2  
  1         36  
5 1     1   5 use warnings;
  1         18  
  1         71  
6            
7             =head1 NAME
8            
9             WSDL::XML::Generator - The way WSDL::XML::Generator is creating a lots of xml with WSDL file by wsdl name and type name.
10            
11             =head1 VERSION
12            
13             Version 0.02
14            
15             =cut
16            
17             our $VERSION = '0.02';
18            
19             =head1 SYNOPSIS
20            
21             1. Just find out Type in WSDL file, write test xml sample, it may be modified to your enviroment, because the generated xml file not related message/portType/service, in here, i supposed the portType type and message are having the same name.
22            
23             2. Secondly, the WSDL file always has xsd schema file that defined all data types, you need fill the xml content by the those types.
24            
25             use WSDL::XML::Generator qw( write list_data_node );
26             write('t/test.wsdl');
27             list_data_node('t/test.wsdl');
28            
29             =head1 EXPORT
30            
31             write list_data_node
32            
33             =head1 SUBROUTINES/METHODS
34            
35             =head2
36            
37             write()
38            
39             list_data_node()
40            
41             =cut
42            
43 1     1   5 use Carp;
  1         9  
  1         79  
44 1     1   6 use Exporter;
  1         2  
  1         45  
45 1     1   416 use File::Slurp qw(read_file write_file);
  0            
  0            
46             use XML::Simple qw(XMLin);
47             our @ISA = qw( Exporter );
48             our @EXPORT = qw( write list_data_node );
49            
50             sub write {
51             my $wsdl_file = shift;
52             my $element_name;
53             my ($file_name_prex) = $wsdl_file =~ /(\w+)\.wsdl/;
54             my @lines = read_file($wsdl_file);
55             foreach (@lines) {
56             if ( // .. /<\/types>/ ) {
57             if ( // .. /<\/xsd:element>/ ) {
58             $element_name =
59             // ? $1 : $element_name;
60             my $output_xml = $file_name_prex . '_' . $element_name . '.xml';
61             if ( // .. /<\/xsd:sequence>/ ) {
62             if (//) {
63             my $name = $1;
64             write_file( $output_xml, { append => 1 },
65             "<$name>$name<\/$name>" );
66             }
67             }
68             }
69             }
70             }
71             return 1;
72             }
73            
74             sub list_data_node {
75             my $wsdl_file = shift;
76             my $hash = XMLin($wsdl_file,ForceArray=>1,KeyAttr=>['xsd:element']);
77             use Data::Dumper qw(Dumper);
78             $Data::Dumper::Indent =3;
79             $Data::Dumper::Pair = " : ";
80             warn Dumper($hash);
81            
82             }
83            
84             =head1 AUTHOR
85            
86             Linus, C<< >>
87            
88             =head1 BUGS
89            
90             Please report any bugs or feature requests to C, or through
91             the web interface at L. I will be notified, and then you'll
92             automatically be notified of progress on your bug as I make changes.
93            
94            
95            
96            
97             =head1 SUPPORT
98            
99             You can find documentation for this module with the perldoc command.
100            
101             perldoc WSDL::XML::Generator
102            
103            
104             You can also look for information at:
105            
106             =over 4
107            
108             =item * RT: CPAN's request tracker (report bugs here)
109            
110             L
111            
112             =item * AnnoCPAN: Annotated CPAN documentation
113            
114             L
115            
116             =item * CPAN Ratings
117            
118             L
119            
120             =item * Search CPAN
121            
122             L
123            
124             =back
125            
126            
127             =head1 ACKNOWLEDGEMENTS
128            
129            
130             =head1 LICENSE AND COPYRIGHT
131            
132             Copyright 2012 Linus.
133            
134             This program is free software; you can redistribute it and/or modify it
135             under the terms of either: the GNU General Public License as published
136             by the Free Software Foundation; or the Artistic License.
137            
138             See http://dev.perl.org/licenses/ for more information.
139            
140            
141             =cut
142            
143             1; # End of WSDL::XML::Generator