[Xml-compile] Schemas with mixed elements

Mark Overmeer mark at overmeer.net
Mon Aug 11 20:12:09 BST 2008


* Drew Taylor (drew at drewtaylor.com) [080811 17:16]:
> I can use a hashref to specify the attributes of given mixed element,  
> but must pass an XML::LibXML::Node object for the nested elements/ 
> text. The $64k question is: how can I create the nodes as easily as I  
> can create non-mixed XML?

mixed elements are a pain, because... they are not structured as a
HASH or ARRAY... a mixed mess.  You have (since release 0.89) the
options
  . mixed_elements => STRUCTURED
    to ignore the "mixedness" of them (may make exceptions with hooks)
    ignoring the text between elements.

  . mixed_elements => ATTRIBUTES
    not to parse the node content, but only the attributes.

> Here's an example I'm dealing with.

>  <Control>
>  <Requester Channel="Extranet" Code="TO-TEST-PV">
>  <Company Is="TourOperator">
>  <Code Role="Rebate" Value="xxx" Name="salesContractId"/> </Company>
>  <Country Code="FR"/> </Requester> </Control>

>  <Style Direction="Out"><Language Code="EN"/></Style>

Both nicely structured.
In most schema's I have seen, "mixed" was abused.

> But it appears that for the Requester element I have to construct an  
> XML::LibXML node, and also for the Language element. 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?

XML::Simple::XMLout() ?   Probably not.
-- 
               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