[Xml-compile] Mixed content question

Petar Shangov pshangov at yahoo.com
Fri Feb 27 14:46:02 GMT 2009


Hi,

I have an element, 'parent', which contains one child element 'mixed_child' with the mixed property set to true. I am using an XML::Compile writer to create this element, and I want the mixed_child to contain just text content for now. How do I produce '<parent><mixed_child>Some Text</mixed_child></parent>'? The best I have come up with is $xml_hash->{'parent'}->{'mixed_child'}->{'_'} = XML::LibXML::Text->new("Some Text"), but this produces '<parent>Some Text</parent>' instead, which is not what I need. 

Here is the definition of the parent element ('tuv')
    <xs:element name="tuv">
        <xs:complexType>
            <xs:sequence>
                <xs:choice minOccurs="0" maxOccurs="unbounded">
                    <xs:element ref="tmx:note"/>
                    <xs:element ref="tmx:prop"/>
                </xs:choice>
                <xs:element ref="tmx:seg"/>
                <xs:any maxOccurs="unbounded" minOccurs="0" namespace="##other" processContents="lax"/>
            </xs:sequence>
            <xs:attribute ref="xml:lang" use="required"/>
            <xs:attribute name="o-encoding"/>
            <xs:attribute name="datatype" default="unknown" type="tmx:datatype"/>
            <xs:attribute name="usagecount"/>
            <xs:attribute name="lastusagedate"/>
            <xs:attribute name="creationtool"/>
            <xs:attribute name="creationtoolversion"/>
            <xs:attribute name="creationdate"/>
            <xs:attribute name="creationid"/>
            <xs:attribute name="changedate"/>
            <xs:attribute name="o-tmf"/>
            <xs:attribute name="changeid"/>
            <xs:anyAttribute namespace="##any" processContents="lax"/>
        </xs:complexType>
    </xs:element>

Here is the definition of the mixed child ('seg')
    <xs:element name="seg">
        <xs:complexType mixed="true">
            <xs:choice minOccurs="0" maxOccurs="unbounded">
                <xs:element ref="tmx:bpt"/>
                <xs:element ref="tmx:ept"/>
                <xs:element ref="tmx:ph"/>
                <xs:element ref="tmx:hi"/>
                <xs:element ref="tmx:x"/>
                <xs:element ref="tmx:g"/>
            </xs:choice>
            <xs:attribute ref="xml:space" default="default"/>
            <xs:anyAttribute namespace="##any" processContents="lax"/>
        </xs:complexType>
    </xs:element>

Thanks!

Petar




More information about the Xml-compile mailing list