[Xml-compile] Schemas with mixed elements

Drew Taylor drew at drewtaylor.com
Mon Aug 11 18:16:33 BST 2008


Hi all,

I have the pleasure of working with a schema which has lots of  
complexTypes that allow mixed elements (<complexType name="FooType"  
mixed="true">). If it matters, I'll mostly be making requests to a  
service and parsing the response. It seems that this is generally not  
well supported based on my reading of the docs and experimentation. 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?

Here's an example I'm dealing with. This is how I expected to be able  
to pass the data:

     Control =>
     {
         # <Control>
         # <Requester Channel="Extranet" Code="TO-TEST-PV"> <Company  
Is="TourOperator">
         # <Code Role="Rebate" Value="xxx" Name="salesContractId"/> </ 
Company>
         # <Country Code="FR"/> </Requester> </Control>
         Requester =>  # element
         {
             Channel => 'Extranet',
             Code    => 'TO-TEST-PV',
             Company =>
             {
                 Is => 'TourOperator',
                 Code => { Role => "Rebate", Value => 'xxx', Name =>  
'salesContractId' },
             },
             Country => { Code => 'FR' },
         },
     },
     # <Style Direction="Out"><Language Code="EN"/></Style>
     Style  =>
     {
         Direction => 'Out',  # an attribute
         Language => { Code => 'EN' }, # element
     },


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?

Thanks,
Drew



More information about the Xml-compile mailing list