This is an automated email from the git hooks/post-receive script. kanashiro-guest pushed a commit to branch master in repository libxml-compile-perl.
commit 48f433520cae1ff455f56a7c0a62085e1d292f53 Author: Lucas Kanashiro <kanashiro.dua...@gmail.com> Date: Fri Jul 24 00:25:03 2015 -0300 Imported Upstream version 1.50 --- ChangeLog | 15 +++++- META.json | 2 +- META.yml | 2 +- Makefile.PL | 2 +- README | 12 ++--- lib/XML/Compile.pm | 2 +- lib/XML/Compile.pod | 4 +- lib/XML/Compile/FAQ.pod | 4 +- lib/XML/Compile/Iterator.pm | 2 +- lib/XML/Compile/Iterator.pod | 4 +- lib/XML/Compile/Schema.pm | 2 +- lib/XML/Compile/Schema.pod | 4 +- lib/XML/Compile/Schema/BuiltInFacets.pm | 2 +- lib/XML/Compile/Schema/BuiltInFacets.pod | 4 +- lib/XML/Compile/Schema/BuiltInTypes.pm | 2 +- lib/XML/Compile/Schema/BuiltInTypes.pod | 4 +- lib/XML/Compile/Schema/Instance.pm | 2 +- lib/XML/Compile/Schema/Instance.pod | 4 +- lib/XML/Compile/Schema/NameSpaces.pm | 2 +- lib/XML/Compile/Schema/NameSpaces.pod | 4 +- lib/XML/Compile/Schema/Specs.pm | 2 +- lib/XML/Compile/Schema/Specs.pod | 4 +- lib/XML/Compile/Translate.pm | 83 ++++++++++++++++++++------------ lib/XML/Compile/Translate.pod | 4 +- lib/XML/Compile/Translate/Reader.pm | 16 +++--- lib/XML/Compile/Translate/Reader.pod | 4 +- lib/XML/Compile/Translate/Template.pm | 2 +- lib/XML/Compile/Translate/Template.pod | 4 +- lib/XML/Compile/Translate/Writer.pm | 29 ++++++----- lib/XML/Compile/Translate/Writer.pod | 4 +- lib/XML/Compile/Util.pm | 2 +- lib/XML/Compile/Util.pod | 4 +- t/TestTools.pm | 2 +- 33 files changed, 141 insertions(+), 98 deletions(-) diff --git a/ChangeLog b/ChangeLog index d81d4bc..aba8c5f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,6 +6,19 @@ Mark Overmeer. Plans and unwanted limitations? see README.todo +version 1.50: di jul 21 17:35:33 CEST 2015 + + Changes: + - input of simpletype hooks is now a simpletype + + Fixes: + - root elements cannot be substituted + - nested substitutionGroup's (broken since 1.44) + - multi-level fallback type inheritance for substGroups + + Improvements: + - writer: minor improvements in hooks + version 1.49: Thu Jun 11 09:40:55 CEST 2015 Fixes: @@ -68,7 +81,7 @@ version 1.44: Wed May 28 09:23:24 CEST 2014 - template XML: show attributes not as elements - template XML: XML compatible example for list elements - memory-leak keeping ::Reader and ::Writer objects [Michiel Ootjers] - - no not accept to read NIL when not nillable + - do not accept to read NIL when not nillable Improvements: - ::Util new functions add_duration() and duration2secs() tests diff --git a/META.json b/META.json index 5398af1..9640306 100644 --- a/META.json +++ b/META.json @@ -48,5 +48,5 @@ } }, "release_status" : "stable", - "version" : "1.49" + "version" : "1.50" } diff --git a/META.yml b/META.yml index aa15485..10554dc 100644 --- a/META.yml +++ b/META.yml @@ -30,4 +30,4 @@ requires: XML::Compile::Tester: 0.9 XML::LibXML: 2.01 bignum: 0.1 -version: 1.49 +version: 1.50 diff --git a/Makefile.PL b/Makefile.PL index e007f6d..8f24cc4 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -4,7 +4,7 @@ use 5.008; WriteMakefile ( NAME => 'XML::Compile' - , VERSION => '1.49' + , VERSION => '1.50' , PREREQ_PM => { XML::LibXML => 2.0100 diff --git a/README b/README index bf2a96a..5e426a4 100644 --- a/README +++ b/README @@ -1,5 +1,5 @@ -=== README for XML-Compile version 1.49 -= Generated on Thu Jun 11 09:42:18 2015 by OODoc 2.01 +=== README for XML-Compile version 1.50 += Generated on Tue Jul 21 17:35:41 2015 by OODoc 2.01 There are various ways to install this module: @@ -9,16 +9,16 @@ There are various ways to install this module: (2) if you use Windows, have a look at http://ppm.activestate.com/ (3) if you have downloaded this module manually (as root/administrator) - gzip -d XML-Compile-1.49.tar.gz - tar -xf XML-Compile-1.49.tar - cd XML-Compile-1.49 + gzip -d XML-Compile-1.50.tar.gz + tar -xf XML-Compile-1.50.tar + cd XML-Compile-1.50 perl Makefile.PL make # optional make test # optional make install For usage, see the included manual-pages or - http://search.cpan.org/dist/XML-Compile-1.49/ + http://search.cpan.org/dist/XML-Compile-1.50/ Please report problems to http://rt.cpan.org/Dist/Display.html?Queue=XML-Compile diff --git a/lib/XML/Compile.pm b/lib/XML/Compile.pm index c07221d..e6eff5a 100644 --- a/lib/XML/Compile.pm +++ b/lib/XML/Compile.pm @@ -8,7 +8,7 @@ use strict; package XML::Compile; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use Log::Report 'xml-compile'; diff --git a/lib/XML/Compile.pod b/lib/XML/Compile.pod index 8998da4..9bbf1a8 100644 --- a/lib/XML/Compile.pod +++ b/lib/XML/Compile.pod @@ -295,8 +295,8 @@ other modules. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/FAQ.pod b/lib/XML/Compile/FAQ.pod index 68bd589..5fbdd3e 100644 --- a/lib/XML/Compile/FAQ.pod +++ b/lib/XML/Compile/FAQ.pod @@ -214,8 +214,8 @@ Try turning on debugging with: =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Iterator.pm b/lib/XML/Compile/Iterator.pm index b3ff6f3..1f11276 100644 --- a/lib/XML/Compile/Iterator.pm +++ b/lib/XML/Compile/Iterator.pm @@ -7,7 +7,7 @@ use strict; package XML::Compile::Iterator; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use XML::Compile::Util qw/pack_type type_of_node SCHEMA2001i/; diff --git a/lib/XML/Compile/Iterator.pod b/lib/XML/Compile/Iterator.pod index 5bf2a8f..4d3617d 100644 --- a/lib/XML/Compile/Iterator.pod +++ b/lib/XML/Compile/Iterator.pod @@ -132,8 +132,8 @@ Returns the textContent of the L<node()|XML::Compile::Iterator/"Attributes">, or =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema.pm b/lib/XML/Compile/Schema.pm index 29d7f08..b386130 100644 --- a/lib/XML/Compile/Schema.pm +++ b/lib/XML/Compile/Schema.pm @@ -5,7 +5,7 @@ package XML::Compile::Schema; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'XML::Compile'; diff --git a/lib/XML/Compile/Schema.pod b/lib/XML/Compile/Schema.pod index d96ce03..e66ad87 100644 --- a/lib/XML/Compile/Schema.pod +++ b/lib/XML/Compile/Schema.pod @@ -1714,8 +1714,8 @@ then still only one prefix is added. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema/BuiltInFacets.pm b/lib/XML/Compile/Schema/BuiltInFacets.pm index 27d1f2a..88f40f4 100644 --- a/lib/XML/Compile/Schema/BuiltInFacets.pm +++ b/lib/XML/Compile/Schema/BuiltInFacets.pm @@ -8,7 +8,7 @@ no warnings 'recursion'; package XML::Compile::Schema::BuiltInFacets; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'Exporter'; diff --git a/lib/XML/Compile/Schema/BuiltInFacets.pod b/lib/XML/Compile/Schema/BuiltInFacets.pod index 018785d..2658770 100644 --- a/lib/XML/Compile/Schema/BuiltInFacets.pod +++ b/lib/XML/Compile/Schema/BuiltInFacets.pod @@ -32,8 +32,8 @@ The content is not for end-users, but called by the schema translator. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema/BuiltInTypes.pm b/lib/XML/Compile/Schema/BuiltInTypes.pm index af08144..3a7bb96 100644 --- a/lib/XML/Compile/Schema/BuiltInTypes.pm +++ b/lib/XML/Compile/Schema/BuiltInTypes.pm @@ -8,7 +8,7 @@ no warnings 'recursion'; package XML::Compile::Schema::BuiltInTypes; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'Exporter'; diff --git a/lib/XML/Compile/Schema/BuiltInTypes.pod b/lib/XML/Compile/Schema/BuiltInTypes.pod index d17dcdb..7ff2def 100644 --- a/lib/XML/Compile/Schema/BuiltInTypes.pod +++ b/lib/XML/Compile/Schema/BuiltInTypes.pod @@ -365,8 +365,8 @@ Probably the same rules as L<anyURI()|XML::Compile::Schema::BuiltInTypes/"URI">. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema/Instance.pm b/lib/XML/Compile/Schema/Instance.pm index 85f36ec..837b366 100644 --- a/lib/XML/Compile/Schema/Instance.pm +++ b/lib/XML/Compile/Schema/Instance.pm @@ -8,7 +8,7 @@ use strict; package XML::Compile::Schema::Instance; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use Log::Report 'xml-compile', syntax => 'SHORT'; diff --git a/lib/XML/Compile/Schema/Instance.pod b/lib/XML/Compile/Schema/Instance.pod index d005050..7628c88 100644 --- a/lib/XML/Compile/Schema/Instance.pod +++ b/lib/XML/Compile/Schema/Instance.pod @@ -176,8 +176,8 @@ anyway). =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema/NameSpaces.pm b/lib/XML/Compile/Schema/NameSpaces.pm index 8da937f..c104445 100644 --- a/lib/XML/Compile/Schema/NameSpaces.pm +++ b/lib/XML/Compile/Schema/NameSpaces.pm @@ -8,7 +8,7 @@ use strict; package XML::Compile::Schema::NameSpaces; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use Log::Report 'xml-compile', syntax => 'SHORT'; diff --git a/lib/XML/Compile/Schema/NameSpaces.pod b/lib/XML/Compile/Schema/NameSpaces.pod index f818a99..27537e7 100644 --- a/lib/XML/Compile/Schema/NameSpaces.pod +++ b/lib/XML/Compile/Schema/NameSpaces.pod @@ -148,8 +148,8 @@ This method implements L<XML::Compile::Schema::useSchema()|XML::Compile::Schema/ =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Schema/Specs.pm b/lib/XML/Compile/Schema/Specs.pm index 1d44e29..44d2211 100644 --- a/lib/XML/Compile/Schema/Specs.pm +++ b/lib/XML/Compile/Schema/Specs.pm @@ -8,7 +8,7 @@ use strict; package XML::Compile::Schema::Specs; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use Log::Report 'xml-compile', syntax => 'SHORT'; diff --git a/lib/XML/Compile/Schema/Specs.pod b/lib/XML/Compile/Schema/Specs.pod index 4dff0e0..7a2d306 100644 --- a/lib/XML/Compile/Schema/Specs.pod +++ b/lib/XML/Compile/Schema/Specs.pod @@ -58,8 +58,8 @@ Returns the uri of all predefined schemas. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Translate.pm b/lib/XML/Compile/Translate.pm index 29d7209..6063e22 100644 --- a/lib/XML/Compile/Translate.pm +++ b/lib/XML/Compile/Translate.pm @@ -8,7 +8,7 @@ no warnings 'recursion'; # trees can be quite deep package XML::Compile::Translate; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; # Errors are either in _class 'usage': called with request @@ -103,7 +103,7 @@ sub compile($@) } delete $self->{_created}; - my $produce = $self->topLevel($path, $item); + my $produce = $self->topLevel($path, $item, 1); delete $self->{_created}; my $in = $self->{include_namespaces} @@ -197,8 +197,8 @@ sub nsContext($) sub namespaces() { $_[0]->{nss} } -sub topLevel($$) -{ my ($self, $path, $fullname) = @_; +sub topLevel($$;$) +{ my ($self, $path, $fullname, $is_root) = @_; # built-in types have to be handled differently. my $internal = XML::Compile::Schema::Specs->builtInType(undef, $fullname @@ -238,7 +238,7 @@ sub topLevel($$) my $name = $node->localName; my $data; if($name eq 'element') - { my ($label, $make) = $self->element($tree); + { my ($label, $make) = $self->element($tree, $is_root); $data = $self->makeElementWrapper($path, $make) if $make; } elsif($name eq 'attribute') @@ -525,8 +525,8 @@ sub applySimpleFacets($$$$) : $self->makeFacets($where, $st, \%facets_info, @early, @late); } -sub element($) -{ my ($self, $tree) = @_; +sub element($;$) +{ my ($self, $tree, $is_root) = @_; # attributes: abstract, default, fixed, form, id, maxOccurs, minOccurs # , name, nillable, ref, substitutionGroup, targetNamespace, type @@ -587,19 +587,39 @@ sub element($) local $self->{_context} = $context if $is_global; my $nodetype = $qual ? $fullname : $name; + # SubstitionGroups + # We know the type of the message root, so do not need to look for + # alternative sgs (and it wouldn't work anyway) + + my @sgs; + @sgs = $self->namespaces->findSgMembers($node->localName, $fullname) + unless $is_root; + # Handle re-usable fragments, fight against combinatorial explosions my $nodeid = $node->unique_key; #$node->nodePath.'#'.$fullname; - my $already = $self->{_created}{$nodeid}; -#warn "$nodeid; ", $node+0,"\n" if $already; -#undef $already; - return ($nodetype, $already) if $already; + if(my $already = $self->{_created}{$nodeid}) + { # We cannot cache compile subst-group handlers, because sgs using + # elements which were already compiled into sgs does not work. + $already = $self->substitutionGroup($tree, $fullname, $nodetype + , $already, \@sgs) if @sgs; + return ($nodetype, $already); + } # Detect recursion + # Very complicated: recursively nested structures. It is less of a + # problem when you handle in run-time what you see... but we here + # have to be prepared for everything. if(exists $self->{_nest}{$nodeid}) - { my $outer = \$self->{_nest}{$nodeid}; - return ($nodetype, sub { $$outer->(@_) }); + { my $outer = \$self->{_nest}{$nodeid}; + my $nested = sub { $$outer->(@_) }; + + # The code must be blessed in the right class, to be compiled + # correctly inside its parent. + bless $nested, 'BLOCK' if @sgs; + + return ($nodetype, $nested); } $self->{_nest}{$nodeid} = undef; @@ -623,16 +643,21 @@ sub element($) || $self->typeByName($where, $tree, $comptype); } elsif($nr_childs==0) - { if(my $subst = $node->getAttribute('substitutionGroup')) - { # default type for substGroups is type of base-class - my $subst_elem = $self->rel2abs($where, $node, $subst); + { # default type for substGroups is type of base-class + my $base_node = $node; + local $self->{_context}; + while(my $subst = $base_node->getAttribute('substitutionGroup')) + { my $subst_elem = $self->rel2abs($where, $base_node, $subst); my $base_elem = $self->namespaces->find(element => $subst_elem); - my $node = $base_elem->{node}; - if(my $isa = $node->getAttribute('type')) - { $comptype = $self->rel2abs($where, $node, $isa); - $comps = $self->blocked($where, complexType => $comptype) - || $self->typeByName($where, $tree, $comptype); - } + $self->{_context} = $self->nsContext($base_elem); + $base_node = $base_elem->{node}; + my $isa = $base_node->getAttribute('type') + or next; + + $comptype = $self->rel2abs($where, $base_node, $isa); + $comps = $self->blocked($where, complexType => $comptype) + || $self->typeByName($where, $tree, $comptype); + last; } unless($comptype) { # no type found, so anyType @@ -711,15 +736,14 @@ sub element($) $do = $self->xsiType($tree, $node, $name, $comptype, $do) if $comptype && $self->{xsi_type}{$comptype}; - if($is_global) - { my @sgs = $self->namespaces->findSgMembers($node->localName, $fullname); - $do = $self->substitutionGroup($tree, $fullname, $nodetype, $do, \@sgs) - if @sgs; - } - $do = $self->addTypeAttribute($comptype, $do) if $self->{xsi_type_everywhere} && $comptype !~ /^unnamed /; + $self->{_created}{$nodeid} = $do; + + $do = $self->substitutionGroup($tree, $fullname, $nodetype, $do, \@sgs) + if @sgs; + # handle recursion # this must look very silly to you... however, this is resolving # recursive schemas: this way nested use of the same element @@ -727,7 +751,6 @@ sub element($) $self->{_nest}{$nodeid} = $do; delete $self->{_nest}{$nodeid}; # clean the outer definition - $self->{_created}{$nodeid} = $do; ($nodetype, $do); } @@ -929,7 +952,7 @@ sub substitutionGroup($$$$$) push @elems, $label => [$self->keyRewrite($label), $base] if $base; foreach my $subst (@$sgs) - { my ($l, $d) = $self->element($tree->descend($subst->{node})); + { my ($l, $d) = $self->element($tree->descend($subst->{node}), 1); push @elems, $l => [$self->keyRewrite($l), $d] if defined $d; } diff --git a/lib/XML/Compile/Translate.pod b/lib/XML/Compile/Translate.pod index 88c6cad..c54d7d9 100644 --- a/lib/XML/Compile/Translate.pod +++ b/lib/XML/Compile/Translate.pod @@ -396,8 +396,8 @@ element does not contains sub-elements, otherwise the XML node. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Translate/Reader.pm b/lib/XML/Compile/Translate/Reader.pm index e59056b..e3cd4ff 100644 --- a/lib/XML/Compile/Translate/Reader.pm +++ b/lib/XML/Compile/Translate/Reader.pm @@ -4,7 +4,7 @@ # Pod stripped from pm file by OODoc 2.01. package XML::Compile::Translate::Reader; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'XML::Compile::Translate'; @@ -14,7 +14,7 @@ no warnings 'once', 'recursion'; use Log::Report 'xml-compile', syntax => 'SHORT'; use List::Util qw/first/; -use Scalar::Util qw/weaken/; +use Scalar::Util qw/weaken blessed/; use XML::Compile::Util qw/pack_type odd_elements type_of_node SCHEMA2001i/; use XML::Compile::Iterator (); @@ -78,7 +78,7 @@ sub makeElementWrapper { my ($self, $path, $processor) = @_; # no copy of $_[0], because it may be a large string sub { my $tree; - if(ref $_[0] && UNIVERSAL::isa($_[0], 'XML::LibXML::Iterator')) + if(blessed $_[0] && $_[0]->isa('XML::LibXML::Iterator')) { $tree = $_[0]; } else @@ -139,6 +139,7 @@ sub makeSequence($@) sub { my $tree = shift; my @res; my @do = @pairs; + while(@do) { my ($take, $do) = (shift @do, shift @do); push @res, ref $do eq 'BLOCK' @@ -224,8 +225,9 @@ sub makeChoice($@) or error __x"choice needs more elements at {path}" , path => $path, _class => 'misfit'; + my @elems = sort keys %do; - trace "choose element from @elems or fix special" if @elems; + trace "choose element from @elems or fix special at $path" if @elems; trace "failed specials in choice: $_" for @special_errors; error __x"no applicable choice for `{tag}' at {path}" @@ -588,7 +590,7 @@ sub _not_processed($$) sub makeComplexElement { my ($self, $path, $tag, $elems, $attrs, $attrs_any,undef,$is_nillable) = @_; -my @e = @$elems; my @a = @$attrs; +#my @e = @$elems; my @a = @$attrs; my @elems = odd_elements @$elems; my @attrs = (odd_elements(@$attrs), @$attrs_any); @@ -931,7 +933,7 @@ sub makeSubstgroup sub { my $tree = shift; my $type = ($tree ? $tree->currentType : undef) or error __x"no data for substitution group {type} at {path}" - , type => $base, path => $path; + , type => $base, path => $path, class => 'misfit'; my $do = $do{$type} or return (); my @subst = $do->[1]($tree->descend); @@ -1113,7 +1115,7 @@ sub makeHook($$$$$$$) : $process->(); @h or return (); - my $h = @h==1 && !ref $h[0] ? {_ => $h[0]} : $h[1]; # detect simpleType + my $h = @h==1 ? $h[0] : $h[1]; # detect simpleType foreach my $after (@after) { $h = $after->($xml, $h, $path, $fulltype); defined $h or return (); diff --git a/lib/XML/Compile/Translate/Reader.pod b/lib/XML/Compile/Translate/Reader.pod index 3a20455..767587b 100644 --- a/lib/XML/Compile/Translate/Reader.pod +++ b/lib/XML/Compile/Translate/Reader.pod @@ -301,8 +301,8 @@ with some extra checks. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Translate/Template.pm b/lib/XML/Compile/Translate/Template.pm index 68389b6..4cc3dbc 100644 --- a/lib/XML/Compile/Translate/Template.pm +++ b/lib/XML/Compile/Translate/Template.pm @@ -5,7 +5,7 @@ package XML::Compile::Translate::Template; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'XML::Compile::Translate'; diff --git a/lib/XML/Compile/Translate/Template.pod b/lib/XML/Compile/Translate/Template.pod index 6240174..5fb62b1 100644 --- a/lib/XML/Compile/Translate/Template.pod +++ b/lib/XML/Compile/Translate/Template.pod @@ -83,8 +83,8 @@ of the specified class. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Translate/Writer.pm b/lib/XML/Compile/Translate/Writer.pm index b1ec90b..03d33ab 100644 --- a/lib/XML/Compile/Translate/Writer.pm +++ b/lib/XML/Compile/Translate/Writer.pm @@ -5,7 +5,7 @@ package XML::Compile::Translate::Writer; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'XML::Compile::Translate'; @@ -482,7 +482,6 @@ sub nil($) sub makeComplexElement { my ($self, $path, $tag, $elems, $attrs, $any_attr,undef, $is_nillable) = @_; -my @e = @$elems; my @elems = odd_elements @$elems; my @attrs = @$attrs; my $tags = join ', ', grep defined @@ -1061,29 +1060,35 @@ sub makeHook($$$$$$$) { my ($self, $path, $r, $tag, $before, $replace, $after, $fulltype) = @_; return $r unless $before || $replace || $after; - error __x"writer only supports one production (replace) hook" - if $replace && @$replace > 1; + my $do_replace; + if($replace) + { return sub {()} if grep $_ eq 'SKIP', @$replace; - return sub {()} if $replace && grep $_ eq 'SKIP', @$replace; + # Input for replace is Perl, output is XML... so we cannot stack them + error __x"writer only supports one replace hook (for {type})" + , type => $fulltype + if @$replace > 1; - my @replace = $replace ? map $self->_decodeReplace($path,$_), @$replace :(); - my @before = $before ? map $self->_decodeBefore($path,$_), @$before :(); - my @after = $after ? map $self->_decodeAfter($path,$_), @$after :(); + $do_replace = $self->_decodeReplace($path, $replace->[0]); + } + + my @do_before = $before ? map $self->_decodeBefore($path,$_), @$before :(); + my @do_after = $after ? map $self->_decodeAfter($path,$_), @$after :(); sub { my ($doc, $val) = @_; defined $val or return; - foreach (@before) + foreach (@do_before) { $val = $_->($doc, $val, $path, $fulltype); defined $val or return (); } - my $xml = @replace - ? $replace[0]->($doc, $val, $path, $tag, $r, $fulltype) + my $xml = $do_replace + ? $do_replace->($doc, $val, $path, $tag, $r, $fulltype) : $r->($doc, $val); defined $xml or return (); - foreach (@after) + foreach (@do_after) { $xml = $_->($doc, $xml, $path, $val, $fulltype); defined $xml or return (); } diff --git a/lib/XML/Compile/Translate/Writer.pod b/lib/XML/Compile/Translate/Writer.pod index 07b8520..ecf5a08 100644 --- a/lib/XML/Compile/Translate/Writer.pod +++ b/lib/XML/Compile/Translate/Writer.pod @@ -216,8 +216,8 @@ writer considerably. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/lib/XML/Compile/Util.pm b/lib/XML/Compile/Util.pm index bb5241c..6402edd 100644 --- a/lib/XML/Compile/Util.pm +++ b/lib/XML/Compile/Util.pm @@ -7,7 +7,7 @@ use strict; package XML::Compile::Util; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'Exporter'; diff --git a/lib/XML/Compile/Util.pod b/lib/XML/Compile/Util.pod index fd4ad2b..deb57d3 100644 --- a/lib/XML/Compile/Util.pod +++ b/lib/XML/Compile/Util.pod @@ -111,8 +111,8 @@ Translate an XML::LibXML::Node into a packed type. =head1 SEE ALSO -This module is part of XML-Compile distribution version 1.49, -built on June 11, 2015. Website: F<http://perl.overmeer.net/xml-compile/> +This module is part of XML-Compile distribution version 1.50, +built on juli 21, 2015. Website: F<http://perl.overmeer.net/xml-compile/> Other distributions in this suite: L<XML::Compile>, diff --git a/t/TestTools.pm b/t/TestTools.pm index 5cd2a11..4a46c17 100644 --- a/t/TestTools.pm +++ b/t/TestTools.pm @@ -7,7 +7,7 @@ use strict; package TestTools; use vars '$VERSION'; -$VERSION = '1.49'; +$VERSION = '1.50'; use base 'Exporter'; -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libxml-compile-perl.git _______________________________________________ Pkg-perl-cvs-commits mailing list Pkg-perl-cvs-commits@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-perl-cvs-commits