oh, look, ComplexType.pm has cut and paste hash reversing code

from SimpleType.pm.  that means that we can cut and paste the
fix from SimpleType.pm into ComplexType.pm.  how many wrongs
make a right?  I forget.
This commit is contained in:
Scott Walters
2014-08-21 07:26:30 -04:00
parent 47dc61bd9e
commit 50c8d5b31f

View File

@@ -98,9 +98,18 @@ sub serialize {
if ( $opt->{ autotype }) {
my $ns = $self->get_targetNamespace();
# reverse namespace by prefix hash
my %prefix_of = reverse %{ $opt->{ namespace } };
my $prefix = $prefix_of{ $ns }
|| die 'No prefix found for namespace '. $ns;
# build a list of hash keys (eg '#default', 'tns') whose values match our namespace (eg 'urn:myNamespace')
(my @possible_namespace_names) = grep { $opt->{ namespace }->{$_} eq $ns } keys %{ $opt->{ namespace } };
# put any '#default' option last
@possible_namespace_names = sort { $a eq '#default' ? 1 : $b eq '#default' ? -1 : $a cmp $b } @possible_namespace_names;
if( grep( $_ ne '#default', @possible_namespace_names ) > 1 or ! @possible_namespace_names ) {
die "no or too many possible names for our namespace of ``$ns'': ``@possible_namespace_names''; there should be just one and maybe a '#default' entry";
}
my $prefix = $possible_namespace_names[0];
$xml .= join q{}, " type=\"$prefix:", $self->get_name(), '" '
if ($self->get_name() );
}