[Xml-compile] Use opts_rw to set the elements_qualified => 'TOP' option value

Patrick Powell papowell at astart.com
Fri Nov 15 00:42:13 GMT 2013


I don't know if this is a documentation error or if I simply do not 
understand the documentation.

There are a couple of options: sloppy_integers => 1, sloppy_floats => 
1.  Also key_rewrite.
Mark Overmeer sent me an example a Looooong time ago,  which I used as a 
template.  Note that in the code
below there is a 'magic' option 'opts_rw' which is glancingly documented 
in the XML::Compile::Cache POD.

Also,  a very confusing note is in the XML::Compile::WSDL11 POD. This 
note states that you cannot pass
the sloppy_integers,  etc.  as an option to 'compileClient'.   It gets 
very confusing.... I wanted to set the
elements_qualified option to 'TOP'.   This causes the top level elements 
to be tagged with their namespace.
I tried several variations of options to cause this to happen but 
nothing appeared to work correctly.

After staring at some of the documentation and looking at the code for a 
while,  I put some trace statements
into the XML::Compile::Translate.pm module to print out the value of the 
elements_qualified option at the place
in the code where it is used to set up the namespace tags for the top 
level elements (actually this is done
in the appropriately named 'topLevel' method).

Much to my surprise the elements_qualified option value was undefined.  
Here is the template I was using.

However, If you pass 'rw_ops => [ ... elements_qualified => 'TOP' ]' it 
does work.
So it appears that some options need to be passed in the 'rw_ops' option 
list.


     # my $wsa  = XML::Compile::SOAP::WSA->new(version => '1.0');

     my @wsdl_fns = bsd_glob( "$schemas/*.wsdl", GLOB_ERR );
     trace __x"WSDL {wsdl}, GLOB_ERROR {ERR}, {MSG}",
         wsdl => join(\@wsdl_fns), ERR => GLOB_ERROR, MSG => $!;
     @wsdl_fns or
         error "WSDL file not found in $schemas directory";
#   @wsdl_fns == 1 or
#       error __x"Multiple WSDL files found in $schemas directory - 
'{wsdl}'",
#           wsdl => join(',', at wsdl_fns);

     my @xsd_fns = bsd_glob( "$schemas/*.xsd" );
     trace __x"XSD {xsd}, GLOB_ERROR {ERR}, {MSG}",
         xsd => Dumper(\@xsd_fns), ERR => GLOB_ERROR, MSG => $!;

     $wsdl   = XML::Compile::WSDL11->new
     ( $wsdl_fns[0]
         , prefixes    => prefix_table()
         , key_rewrite => 'UNDERSCORES'
         # , elements_qualified => 'ALL'
         # , elements_qualified => 'TOP'
         , opts_rw => [ sloppy_integers => 1, sloppy_floats => 1, 
]#elements_qualified => 'TOP' ]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
uncomment this and it works
         , @compile_options
         #   , any_element => 'ATTEMPT'
     );
     shift @wsdl_fns;
     while( @wsdl_fns ){
         $wsdl->addWSDL
         ( $wsdl_fns[0]
             , prefixes    => prefix_table()
             , key_rewrite => 'UNDERSCORES'
             # , elements_qualified => 'ALL'
             # , elements_qualified => 'TOP'
             , opts_rw => [ sloppy_integers => 1, sloppy_floats => 1, ]# 
elements_qualified => 'TOP' ]
             , @compile_options
             #   , any_element => 'ATTEMPT'
         );
         shift @wsdl_fns;
     }
     $wsdl->importDefinitions(\@xsd_fns
             # , elements_qualified => 'TOP'
             # , opts_rw => [ sloppy_integers => 1, sloppy_floats => 1, 
elements_qualified => 'TOP' ]
             # , elements_qualified => 'ALL'
             # , element_form_default=>'qualified'
             # , attribute_form_default=>'qualified'
             , @compile_options
          );

I tried some experimentation,  and it looks like you only need one value 
of elements_qualified,  but it has
to be in the XML:Compile::WSDL11->new parameter list in opts_rw.

Note: these results were obtained by brute force and trial and error.  I 
hope better minds than mine
can clarify the use of the 'opts_rw'  and what options/values it can be 
used to pass to what part the
the XML::Compile chain.



More information about the Xml-compile mailing list