How to define a element involving regular expressions?

Discussion in 'XML' started by D. Alvarado, Jun 22, 2004.

  1. D. Alvarado

    D. Alvarado Guest

    Hello,
    I have an element that I would like to validate against an XML
    schema in which the element can be either one of 50 values or an
    arbitrary number of white space characters. The values would be
    things like "AC", "AD", abd "AF" and you could see the XML element
    represented like:

    <myElt>AC</myElt>

    or

    <myElt>AF</myElt>

    or

    <myElt> </myElt>

    How would I define such an element in an XML schema?
     
    D. Alvarado, Jun 22, 2004
    #1
    1. Advertising

  2. D. Alvarado wrote:
    > Hello,
    > I have an element that I would like to validate against an XML
    > schema in which the element can be either one of 50 values or an
    > arbitrary number of white space characters. The values would be
    > things like "AC", "AD", abd "AF" and you could see the XML element
    > represented like:
    >

    [...]
    > How would I define such an element in an XML schema?


    The boundaries are not too clear, but the following simple type might get
    you on your way:

    <xs:simpleType name="patternType">
    <xs:restriction base="xs:string">
    <xs:pattern value="[ ]{11}|A[C-F]" />
    </xs:restriction>
    </xs:simpleType>


    JW
     
    Janwillem Borleffs, Jun 23, 2004
    #2
    1. Advertising

  3. (D. Alvarado) writes:

    > I have an element that I would like to validate against an XML
    > schema in which the element can be either one of 50 values or an
    > arbitrary number of white space characters. The values would be
    > things like "AC", "AD", abd "AF" and you could see the XML element
    > represented like:
    >
    > <myElt>AC</myElt>
    > or
    > <myElt>AF</myElt>
    > or
    > <myElt> </myElt>
    >
    > How would I define such an element in an XML schema?


    Define a restriction of xs:token with either
    * an enumeration of all your two-letter codes plus the empty string
    or
    * a pattern which allows the empty string plus your two letter codes

    ht
    --
    Henry S. Thompson, HCRC Language Technology Group, University of Edinburgh
    Half-time member of W3C Team
    2 Buccleuch Place, Edinburgh EH8 9LW, SCOTLAND -- (44) 131 650-4440
    Fax: (44) 131 650-4587, e-mail:
    URL: http://www.ltg.ed.ac.uk/~ht/
    [mail really from me _always_ has this .sig -- mail without it is forged spam]
     
    Henry S. Thompson, Jun 24, 2004
    #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. Jay Douglas
    Replies:
    0
    Views:
    643
    Jay Douglas
    Aug 15, 2003
  2. theotyflos
    Replies:
    3
    Views:
    508
    Thomas Matthews
    Feb 19, 2004
  3. HANM
    Replies:
    2
    Views:
    767
    Joseph Kesselman
    Jan 29, 2008
  4. Andrey Vul

    [cpp] using expressions inside a #define label

    Andrey Vul, Oct 23, 2009, in forum: C Programming
    Replies:
    2
    Views:
    1,581
  5. Noman Shapiro
    Replies:
    0
    Views:
    261
    Noman Shapiro
    Jul 17, 2013
Loading...

Share This Page