xml-schema mixed content

I

Imiro

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

<root>string<tag1/></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|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"/>
</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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,901
Latest member
Noble71S45

Latest Threads

Top