Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to define a element involving regular expressions?

Reply
Thread Tools

How to define a element involving regular expressions?

 
 
D. Alvarado
Guest
Posts: n/a
 
      06-22-2004
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?
 
Reply With Quote
 
 
 
 
Janwillem Borleffs
Guest
Posts: n/a
 
      06-23-2004
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">
<xsattern value="[ ]{11}|A[C-F]" />
</xs:restriction>
</xs:simpleType>


JW



 
Reply With Quote
 
 
 
 
Henry S. Thompson
Guest
Posts: n/a
 
      06-24-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (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: (E-Mail Removed)
URL: http://www.ltg.ed.ac.uk/~ht/
[mail really from me _always_ has this .sig -- mail without it is forged spam]
 
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
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
Define a Regular Expresson within a Custom Configuration Section grant.trevor@gmail.com ASP .Net 0 02-04-2007 06:39 PM
About typedef -- define the function pointer or define function model? robin liu C Programming 3 04-21-2006 03:26 PM
#define _ and #define __ Brian Takita Ruby 0 01-23-2006 04:34 AM
How to define a define that defines some defines ? theotyflos C Programming 3 02-19-2004 05:07 PM



Advertisments