[Xml-compile] Schemas with mixed elements

Mark Overmeer mark at overmeer.net
Tue Aug 12 23:23:13 BST 2008


* Drew Taylor (drew at drewtaylor.com) [080812 08:36]:
> * Drew Taylor ([1]drew at drewtaylor.com) [080811 17:16]:
> From my code diving yesterday, it's worth mentioning that the mixed_elements
> => STRUCTURED option stops everything for the Writer.

What do you mean with that?  Example?

> Translate::Writer::makeMixedElement():
>      elsif($mixed eq 'STRUCTURAL')
>      { # mixed_element eq STRUCTURAL is handled earlier
>        panic "mixed structural handled as normal element";
>      }
> Where is STRUCTURAL handled earlier? I didn't see anything obvious from the
> stack trace.

It is much simpler. The ::Translate contains this code:

    my $mixed = $self->isTrue($node->getAttribute('mixed') || 'false');
    undef $mixed if $self->{mixed_elements} eq 'STRUCTURAL';

Which means: if 'STRUCTURED', then simply ignore the mixed attribute ;-)
But it may need to be smarter in future versions.  So: makeMixedElement()
cannot be called in this case.

>  <Price Role="Supplement">blah blah<Segment Ref="CELASSGS"/> <Amounts>
>  <Amount Quantity="1" Target="Unit" Value="3000"/> <Amount Target="Total"
>  Value="3000"/> </Amounts> </Price>
> 
>  Is there a
>  shortcut I can use to reduce the boiler plate I'd be using to generate
>  the XML nodes? How are other people handling mixed schemas?

Probably not.

> XML::Simple::XMLout() ?   Probably not.
> Interesting idea. I think XML::LibXML::Simple could be useful on the server
> side to generate the request. I might see the effort involved in writing
> XML::LibXML::Simple::XMLout()...

I did not write XML::LibXML::Simple::XMLout(), because I think it is a
bad idea in the first place; you cannot DWIM correct output generation.
But if you go into the dark areas, then why not use XML::Simple's version?
-- 
Regards,
               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
drs Mark A.C.J. Overmeer                                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