XSD question: using multiple restriction patterns


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: XSD question: using multiple restriction patterns

  1. #1
    Join Date
    Oct 2009
    Posts
    2

    XSD question: using multiple restriction patterns

    Hi,

    I would like the content of an element to match one of two possible string patterns. How can I implement this?

    Goal:
    <myElement>abcd</myElement>
    or
    <myElement>a1b2</myElement>

    Something like:
    Code:
    <xs:simpleType name="myElement_Type">
      <xs:restriction base="xs:string">
        <xs:choice>
        <xs:pattern value="\w\w\w\w"/>
        <xs:pattern value="\w\d\w\d"/>
        </xs:choice>
      </xs:restriction>
    </xs:simpleType>
    Please note, that the example is a huge simplification. In reality the pattern for each of the choices is a lot more complex.

    Looking forward to receivign your comments.

    Regards,Mos

  2. #2
    Join Date
    Oct 2009
    Posts
    2
    Oh well, sometimes it can be so easy...It seems that this will do the trick:

    Code:
    <xs:simpleType name="myElement_Type">
      <xs:restriction base="xs:string">
        <xs:pattern value="\w\w\w\w"/>
        <xs:pattern value="\w\d\w\d"/>
      </xs:restriction>
    </xs:simpleType>

Similar Threads

  1. Test question: Design patterns & Environments
    By todavidc-temp in forum Java
    Replies: 4
    Last Post: 10-11-2005, 04:48 PM
  2. Display one record at a time!
    By ASP learner in forum ASP.NET
    Replies: 5
    Last Post: 10-08-2002, 07:17 PM
  3. Multiple Parent/Single Child UML Modeling Question
    By Kevin in forum Architecture and Design
    Replies: 1
    Last Post: 06-07-2002, 12:48 PM
  4. question about xsd schema
    By ec in forum XML
    Replies: 2
    Last Post: 01-31-2002, 02:24 PM
  5. XSD question
    By Dave Kraft in forum XML
    Replies: 0
    Last Post: 01-10-2002, 09:08 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center