Limit content of a tag with Schema

jiaqi.guo

Usenet Archive
Joined
Dec 8, 2004
Messages
1
Reaction score
0
I want to limit the content of a tag to be a string or another tag. How can I do it? <mytag att1="abc">Hello World</mytag> or <mytag att1="abc"><tag1>...</tag1></mytag> or <mytag att1="abc"><tag2>...</tag2></mytag>

Only pure text , one <tag1> OR one <tag2> is allowed in <mytag> How should I define <mytag> in schema.

Thanks in advance
Jiaqi
 

Stan Kitsis MSFT

Usenet Archive
Joined
Dec 15, 2004
Messages
64
Reaction score
0
Hi Jiaqi,

You need to use a mixed model to allow both text and other elements within <mytag> element. However, with a mixed model you cannot constrain the position of the text nodes. So if you use it, it will allow text OR tag1 OR tag2 OR text and tag1 OR text and tag2. Also note that in the last two cases the text can appear before, after, or both before and after tag1 or tag2 elements.

Here's an example:

<xs:complexType name="mytag" mixed="true">
<xs:choice minOccurs="0" maxOccurs="1">
<xs:element name="tag1" type="tag1" />
<xs:element name="tag2" type="tag2" />
</xs:choice>
</xs:complexType>
<xs:element name="mytag" type="mytag" />
 

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

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,799
Members
249,594
Latest member
henrywalsh

Latest Threads

Top