[Xml-compile] Schemas with mixed elements

Mark Overmeer mark at overmeer.net
Sun Aug 17 13:31:09 BST 2008


* Drew Taylor (drew at drewtaylor.com) [080813 09:30]:
> It seems to work, but I have to be careful to not pass attribute  
> values in the call to make_element() or I get segfaults. This is  
> really ugly and error prone to say the least.

Segfaults in relation to attributes make me expect you have to upgrade
your libxml2 library.

> A new question: how can I specify a 'xsi:type="foo"' attribute on an  
> element? An example is: <Segment xsi:type="SegmentProductType">. I  
> tried passing " 'xsi:type' => 'foo' " in the data structure but it was  
> ignored.

Please put new questions in a new email thread, to reduce the chance
that I miss them.

On the moment, there are no helpers to achieve this.  Probably, I should
create an option to have these added.  It will be implemented as an
after-hook, which you can also make yourself:

   $schema->addHook(type => $mytype, after =>
      sub { my ($doc, $xml, $path, $val) = @_;
            $xml->setAttribute("xsi:type" => $mytype);
            $xml;
          });

Unconvenient when you have many types which you want to make explicit.
XML::Compile::SOAP::Encoding knows how to do it better.

I have to think about a better solutions, although you should not need
it when using schemas the usual way.
-- 
Regards,

               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark at Overmeer.net                          solutions at overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




More information about the Xml-compile mailing list