Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Limit content of a tag with Schema

Reply
Thread Tools

Limit content of a tag with Schema

 
 
jiaqi.guo@gmail.com
Guest
Posts: n/a
 
      12-08-2004
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

 
Reply With Quote
 
 
 
 
Stan Kitsis [MSFT]
Guest
Posts: n/a
 
      12-15-2004
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" />

--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
>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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
limit on number of content placeholders(which are editable in content pages) in master page nemesis.saurabh@gmail.com ASP .Net 0 05-25-2006 04:44 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
[XML Schema] Content type of complex type definition with complex content Stanimir Stamenkov XML 2 10-25-2005 10:16 AM
[XML Schema] Including a schema document with absent target namespace to a schema with specified target namespace Stanimir Stamenkov XML 3 04-25-2005 09:59 AM
Select text within a div tag by clicking on content of div tag? M Wells Javascript 0 10-06-2004 11:04 AM



Advertisments