xml-schema mixed content

Discussion in 'XML' started by Imiro, Aug 26, 2004.

  1. Imiro

    Imiro Guest

    Hi, i'm trying to express mixed content like this with a schema:

    <root>string<tag1/></root> or <root>string</root> but not

    I guess it would be like this as dtd declaration (though not valid):
    <!ELEMENT root (#PCDATA|tag1|tag2)+>

    I've come up with this, but it doesnt quite do it yet:

    <xs:element name="root" default="string">
    <xs:complexType mixed="true">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="tag1"/>
    <xs:element ref="tag2"/>

    Problem is that i can't extend the choice occurance rules to the
    string "element" of root's content. Giving default value string, makes
    sure its going to be as intended, allthough i'd like an parser
    exception in case root is left empty. If i make minOccurs of choice to
    be one, then it only applies to the actual elements inside the choice.

    Is there a way to do this better? I know theres easy work-arounds by
    adding elements, but in this case the xml file is some what fixed in


    Imiro, Aug 26, 2004
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.