xml-schema mixed content

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Imiro

    #1

    xml-schema mixed content

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

    <root>string<ta g1/></root> or <root>string</root> but not
    <root></root>

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

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

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

    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
    structure.

    Thanks,

    Imiro
Working...