Limit content of a tag with Schema

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jiaqi.guo@gmail.com

    Limit content of a tag with Schema

    I want to limit the content of a tag to be a string or another tag. How
    can I do it?
    <mytag att1="abc">Hell o World</mytag>
    or
    <mytag att1="abc"><tag 1>...</tag1></mytag>
    or
    <mytag att1="abc"><tag 2>...</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]

    #2
    Re: Limit content of a tag with Schema

    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:complexTy pe 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.


    <jiaqi.guo@gmai l.com> wrote in message
    news:1102542928 .487520.264350@ z14g2000cwz.goo glegroups.com.. .[color=blue]
    >I want to limit the content of a tag to be a string or another tag. How
    > can I do it?
    > <mytag att1="abc">Hell o World</mytag>
    > or
    > <mytag att1="abc"><tag 1>...</tag1></mytag>
    > or
    > <mytag att1="abc"><tag 2>...</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
    >[/color]


    Comment

    Working...