| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package W3C::SOAP::XSD::Document::ComplexType; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # Created on: 2012-05-26 19:04:25 | 
| 4 |  |  |  |  |  |  | # Create by:  Ivan Wills | 
| 5 |  |  |  |  |  |  | # $Id$ | 
| 6 |  |  |  |  |  |  | # $Revision$, $HeadURL$, $Date$ | 
| 7 |  |  |  |  |  |  | # $Revision$, $Source$, $Date$ | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 1289 | use Moose; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 10 | 1 |  |  | 1 |  | 5108 | use warnings; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 28 |  | 
| 11 | 1 |  |  | 1 |  | 4 | use version; | 
|  | 1 |  |  |  |  | 3 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 12 | 1 |  |  | 1 |  | 54 | use Carp; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 130 |  | 
| 13 | 1 |  |  | 1 |  | 6 | use Scalar::Util; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 37 |  | 
| 14 | 1 |  |  | 1 |  | 5 | use List::Util; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 47 |  | 
| 15 |  |  |  |  |  |  | #use List::MoreUtils; | 
| 16 | 1 |  |  | 1 |  | 5 | use Data::Dumper qw/Dumper/; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 38 |  | 
| 17 | 1 |  |  | 1 |  | 5 | use English qw/ -no_match_vars /; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 6 |  | 
| 18 | 1 |  |  | 1 |  | 372 | use W3C::SOAP::Utils qw/split_ns/; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | extends 'W3C::SOAP::XSD::Document::Type'; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  | our $VERSION     = version->new('0.11'); | 
| 23 |  |  |  |  |  |  |  | 
| 24 |  |  |  |  |  |  | has sequence => ( | 
| 25 |  |  |  |  |  |  | is      => 'rw', | 
| 26 |  |  |  |  |  |  | isa     => 'ArrayRef[W3C::SOAP::XSD::Document::Element]', | 
| 27 |  |  |  |  |  |  | builder => '_sequence', | 
| 28 |  |  |  |  |  |  | lazy    => 1, | 
| 29 |  |  |  |  |  |  | ); | 
| 30 |  |  |  |  |  |  | has module => ( | 
| 31 |  |  |  |  |  |  | is        => 'rw', | 
| 32 |  |  |  |  |  |  | isa       => 'Str', | 
| 33 |  |  |  |  |  |  | builder   => '_module', | 
| 34 |  |  |  |  |  |  | lazy       => 1, | 
| 35 |  |  |  |  |  |  | ); | 
| 36 |  |  |  |  |  |  | has complex_content => ( | 
| 37 |  |  |  |  |  |  | is        => 'rw', | 
| 38 |  |  |  |  |  |  | isa       => 'Str', | 
| 39 |  |  |  |  |  |  | builder   => '_complex_content', | 
| 40 |  |  |  |  |  |  | lazy       => 1, | 
| 41 |  |  |  |  |  |  | ); | 
| 42 |  |  |  |  |  |  | has extension => ( | 
| 43 |  |  |  |  |  |  | is        => 'rw', | 
| 44 |  |  |  |  |  |  | isa       => 'Maybe[Str]', | 
| 45 |  |  |  |  |  |  | builder   => '_extension', | 
| 46 |  |  |  |  |  |  | lazy       => 1, | 
| 47 |  |  |  |  |  |  | ); | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | sub _sequence { | 
| 50 | 0 |  |  | 0 |  |  | my ($self) = @_; | 
| 51 | 0 |  |  |  |  |  | my ($node) = $self->document->xpc->findnodes('xsd:complexContent/xsd:extension', $self->node); | 
| 52 | 0 | 0 |  |  |  |  | if (!$node) { | 
| 53 | 0 |  |  |  |  |  | ($node) = $self->document->xpc->findnodes('xsd:extension', $self->node); | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  |  | 
| 56 | 0 |  | 0 |  |  |  | return $self->_get_sequence_elements($node || $self->node); | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | sub _module { | 
| 60 | 0 |  |  | 0 |  |  | my ($self) = @_; | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 0 |  | 0 |  |  |  | return $self->document->module . '::' . ( $self->name || $self->parent_node->name ); | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  | sub _complex_content { | 
| 66 | 0 |  |  | 0 |  |  | my ($self) = @_; | 
| 67 |  |  |  |  |  |  |  | 
| 68 | 0 |  | 0 |  |  |  | return $self->document->module . '::' . ( $self->name || $self->parent_node->name ); | 
| 69 |  |  |  |  |  |  | } | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  | sub _extension { | 
| 72 | 0 |  |  | 0 |  |  | my ($self) = @_; | 
| 73 |  |  |  |  |  |  |  | 
| 74 |  |  |  |  |  |  | # TODO $suffix feels like a hack, it fixes the tests but isn't really calculated to be the correct value | 
| 75 | 0 |  |  |  |  |  | my $suffix = ''; | 
| 76 | 0 |  |  |  |  |  | my @nodes = $self->document->xpc->findnodes('xsd:complexContent/xsd:extension', $self->node); | 
| 77 | 0 | 0 |  |  |  |  | if (!@nodes) { | 
| 78 | 0 |  |  |  |  |  | @nodes = $self->document->xpc->findnodes('xsd:extension', $self->node); | 
| 79 | 0 |  |  |  |  |  | $suffix = 'Type'; | 
| 80 |  |  |  |  |  |  | } | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 0 |  |  |  |  |  | for my $node (@nodes) { | 
| 83 | 0 |  |  |  |  |  | my ($ns, $tag) = split_ns($node->getAttribute('base')); | 
| 84 | 0 |  |  |  |  |  | my $ns_uri = $self->document->get_ns_uri($ns, $self->node); | 
| 85 |  |  |  |  |  |  |  | 
| 86 | 0 |  |  |  |  |  | return $self->document->get_module_name( $ns_uri ) . "::$tag" . $suffix; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  |  | 
| 89 | 0 |  |  |  |  |  | return; | 
| 90 |  |  |  |  |  |  | } | 
| 91 |  |  |  |  |  |  |  | 
| 92 |  |  |  |  |  |  | sub _get_sequence_elements { | 
| 93 | 0 |  |  | 0 |  |  | my ($self, $node) = @_; | 
| 94 | 0 |  |  |  |  |  | my @nodes = $self->document->xpc->findnodes('xsd:sequence/*', $node); | 
| 95 | 0 |  |  |  |  |  | my @sequence; | 
| 96 | 0 |  |  |  |  |  | my $group = 1; | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 0 |  |  |  |  |  | for my $node (@nodes) { | 
| 99 | 0 | 0 |  |  |  |  | if ( $node->nodeName =~ /(?:^|:)element$/ ) { | 
|  |  | 0 |  |  |  |  |  | 
| 100 | 0 |  |  |  |  |  | push @sequence, W3C::SOAP::XSD::Document::Element->new( | 
| 101 |  |  |  |  |  |  | parent_node => $self, | 
| 102 |  |  |  |  |  |  | node   => $node, | 
| 103 |  |  |  |  |  |  | ); | 
| 104 |  |  |  |  |  |  | } | 
| 105 |  |  |  |  |  |  | elsif ( $node->nodeName =~ /(?:^|:)choice$/ ) { | 
| 106 | 0 |  |  |  |  |  | my @choices = $self->document->xpc->findnodes('xsd:element', $node); | 
| 107 | 0 |  |  |  |  |  | for my $choice (@choices) { | 
| 108 | 0 |  |  |  |  |  | push @sequence, W3C::SOAP::XSD::Document::Element->new( | 
| 109 |  |  |  |  |  |  | parent_node  => $self, | 
| 110 |  |  |  |  |  |  | node         => $choice, | 
| 111 |  |  |  |  |  |  | choice_group => $group, | 
| 112 |  |  |  |  |  |  | ); | 
| 113 |  |  |  |  |  |  | } | 
| 114 | 0 |  |  |  |  |  | $group++; | 
| 115 |  |  |  |  |  |  | } | 
| 116 |  |  |  |  |  |  | } | 
| 117 |  |  |  |  |  |  |  | 
| 118 | 0 |  |  |  |  |  | return \@sequence; | 
| 119 |  |  |  |  |  |  | } | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | 1; | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | __END__ | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =head1 NAME | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | W3C::SOAP::XSD::Document::ComplexType - Represents complexType elements of XSD documents | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =head1 VERSION | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | This documentation refers to W3C::SOAP::XSD::Document::ComplexType version 0.11. | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  |  | 
| 134 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  | use W3C::SOAP::XSD::Document::ComplexType; | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  | # Brief but working code example(s) here showing the most common usage(s) | 
| 139 |  |  |  |  |  |  | # This section will be as far as many users bother reading, so make it as | 
| 140 |  |  |  |  |  |  | # educational and exemplary as possible. | 
| 141 |  |  |  |  |  |  |  | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | Represents a single XML Schema complex type definition. | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =head1 SUBROUTINES/METHODS | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | =head1 DIAGNOSTICS | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | =head1 CONFIGURATION AND ENVIRONMENT | 
| 152 |  |  |  |  |  |  |  | 
| 153 |  |  |  |  |  |  | =head1 DEPENDENCIES | 
| 154 |  |  |  |  |  |  |  | 
| 155 |  |  |  |  |  |  | =head1 INCOMPATIBILITIES | 
| 156 |  |  |  |  |  |  |  | 
| 157 |  |  |  |  |  |  | =head1 BUGS AND LIMITATIONS | 
| 158 |  |  |  |  |  |  |  | 
| 159 |  |  |  |  |  |  | There are no known bugs in this module. | 
| 160 |  |  |  |  |  |  |  | 
| 161 |  |  |  |  |  |  | Please report problems to Ivan Wills (ivan.wills@gmail.com). | 
| 162 |  |  |  |  |  |  |  | 
| 163 |  |  |  |  |  |  | Patches are welcome. | 
| 164 |  |  |  |  |  |  |  | 
| 165 |  |  |  |  |  |  | =head1 AUTHOR | 
| 166 |  |  |  |  |  |  |  | 
| 167 |  |  |  |  |  |  | Ivan Wills - (ivan.wills@gmail.com) | 
| 168 |  |  |  |  |  |  |  | 
| 169 |  |  |  |  |  |  | =head1 LICENSE AND COPYRIGHT | 
| 170 |  |  |  |  |  |  |  | 
| 171 |  |  |  |  |  |  | Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077). | 
| 172 |  |  |  |  |  |  | All rights reserved. | 
| 173 |  |  |  |  |  |  |  | 
| 174 |  |  |  |  |  |  | This module is free software; you can redistribute it and/or modify it under | 
| 175 |  |  |  |  |  |  | the same terms as Perl itself. See L<perlartistic>.  This program is | 
| 176 |  |  |  |  |  |  | distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; | 
| 177 |  |  |  |  |  |  | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A | 
| 178 |  |  |  |  |  |  | PARTICULAR PURPOSE. | 
| 179 |  |  |  |  |  |  |  | 
| 180 |  |  |  |  |  |  | =cut |