Restrict Data Range

Discussion in 'XML' started by bogus1one@yahoo.com, Dec 8, 2005.

  1. Guest

    To all you XML experts, let's say I have the following in an XML doc:

    <heading units="TRUE">55</heading>

    I would like to develop a schema that will both provide for an
    enumeration for the attribute and restrict the input to some range of
    values. In the example above, I want the enumeration to be restricted
    to TRUE and MAG. And, I want the valid values the text to be 0 through
    359. I seem to be able to get one or the other but not both. This is
    what I have currently:

    <xs:element name="heading">
    <xs:complexType>
    <xs:simpleContent>
    <xs:extension base="xs:unsignedShort">
    <xs:attribute name="units" use="required">
    <xs:simpleType>
    <xs:restriction base="xs:string">
    <xs:enumeration value="TRUE"/>
    <xs:enumeration value="MAG"/>
    </xs:restriction>
    </xs:simpleType>
    </xs:attribute>
    </xs:extension>
    </xs:simpleContent>
    </xs:complexType>
    </xs:element>

    It is my understanding that facets can only be applied to simple types
    and that once you add an attribute to an element, it becomes a complex
    type. So, how do you work around this?

    Thanks for your help.
     
    , Dec 8, 2005
    #1
    1. Advertising

  2. <xs:simpleType name="tfType">

    <xs:restriction base="xs:string">

    <xs:enumeration value="TRUE"/>

    <xs:enumeration value="MAG"/>

    </xs:restriction>

    </xs:simpleType>



    <xs:simpleType name="myNumbers">

    <xs:restriction base="xs:unsignedShort">

    <xs:minInclusive value="0"/>

    <xs:maxInclusive value="359"/>

    </xs:restriction>

    </xs:simpleType>



    <xs:complexType name="headingType">

    <xs:simpleContent>

    <xs:extension base="myNumbers">

    <xs:attribute name="units" type="tfType"/>

    </xs:extension>

    </xs:simpleContent>

    </xs:complexType>



    <xs:element name="heading" type="headingType"/>


    --
    Stan Kitsis
    Program Manager, XML Technologies
    Microsoft Corporation

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Use of included script samples are subject to the terms specified at
    http://www.microsoft.com/info/cpyright.htm


    <> wrote in message
    news:...
    > To all you XML experts, let's say I have the following in an XML doc:
    >
    > <heading units="TRUE">55</heading>
    >
    > I would like to develop a schema that will both provide for an
    > enumeration for the attribute and restrict the input to some range of
    > values. In the example above, I want the enumeration to be restricted
    > to TRUE and MAG. And, I want the valid values the text to be 0 through
    > 359. I seem to be able to get one or the other but not both. This is
    > what I have currently:
    >
    > <xs:element name="heading">
    > <xs:complexType>
    > <xs:simpleContent>
    > <xs:extension base="xs:unsignedShort">
    > <xs:attribute name="units" use="required">
    > <xs:simpleType>
    > <xs:restriction base="xs:string">
    > <xs:enumeration value="TRUE"/>
    > <xs:enumeration value="MAG"/>
    > </xs:restriction>
    > </xs:simpleType>
    > </xs:attribute>
    > </xs:extension>
    > </xs:simpleContent>
    > </xs:complexType>
    > </xs:element>
    >
    > It is my understanding that facets can only be applied to simple types
    > and that once you add an attribute to an element, it becomes a complex
    > type. So, how do you work around this?
    >
    > Thanks for your help.
    >
     
    Stan Kitsis [MSFT], Dec 8, 2005
    #2
    1. Advertising

  3. Guest

    The clouds have lifted!

    Thanks a million.
     
    , Dec 8, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. ad
    Replies:
    5
    Views:
    680
    Mark Rae
    Jun 5, 2005
  2. ad

    How to restrict IP range

    ad, Aug 21, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    434
    Mark Rae
    Aug 21, 2005
  3. Replies:
    46
    Views:
    985
    Antoon Pardon
    Jul 25, 2006
  4. Lambda
    Replies:
    2
    Views:
    411
    James Kanze
    Jul 16, 2008
  5. Tomoyuki Kosimizu

    Range does not take an Range object.

    Tomoyuki Kosimizu, Nov 25, 2003, in forum: Ruby
    Replies:
    3
    Views:
    158
    Tomoyuki Kosimizu
    Nov 27, 2003
Loading...

Share This Page