[XMLSCHEMA-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: regex help

From: Michael Kay <mike@saxonica.com>
Date: Wed, 3 Jan 2007 19:57:36 -0000
To: "'Tsao, Scott'" <scott.tsao@boeing.com>, <xmlschema-dev@w3.org>
Message-ID: <01b101c72f71$6b2e39f0$6401a8c0@turtle>
RE: regex help

Looks to me something like

<xs:simpleType name="quotedString">
  <xs:restriction base="xs:string">
    <xs:pattern value='".*"'/>
  </xs:restriction>
</xs:simpleType>

<xs:simpleType name="listOfQuotedStrings">
  <xs:list itemType="quotedString"/>
</xs:simpleType>

or if you don't want to use a list type,

<xs:simpleType name="listOfQuotedStrings">
  <xs:restriction base="xs:string">
    <xs:pattern value='(("[^"]*")\s+)*'/>
  </xs:restriction></xs:simpleType>
</xs:simpleType> 

But perhaps I've misread you. When you say (The double quote here is chosen
as an arbitrary delimeter and has no special significance.) do you mean you
want to allow the user to choose any delimiter they like? That's difficult
without backreferences.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Tsao, Scott
> Sent: 03 January 2007 19:46
> To: xmlschema-dev@w3.org
> Subject: regex help
> 
> 
> A colleague raised this question below regarding the use of 
> XSD pattern facet.
> 
> Can someone help please?
> 
> Thanks,
> 
> Scott Tsao
> Enterprise Architecture and Integration
> The Boeing Company
> 
> 
> -----Original Message-----
> 
> I'm trying to design a W3C XML Schema type description for an 
> element containing an arbitrary number of quoted strings 
> separated by arbitrary whitespace.  The contents of the 
> quoted items are themselves limited to alphanumerics, 
> whitespace, and common punctuation characters, excluding 
> embedded quote characters.  (The double quote here is chosen 
> as an arbitrary delimeter and has no special significance.)
> 
> Example:
> "abc" "de f" "123_456"
> "foo bar" "etc."
> 
> I'm not aware of a "built-in" XML Schema type that can 
> support this representation directly.  It also appears that 
> the W3C XML Schema "pattern" 
> facet (allowing the specification of a regular expression for a type
> format) does not support the "non-greedy" quantifier syntax, 
> e.g., "*?", "+?" that is common in many regular expression engines.
> 
> Can anyone suggest a regex to define this format without the 
> non-greedy quantifiers, or perhaps an XML Schema 
> representation that can handle this format directly?
> 
Received on Wednesday, 3 January 2007 19:57:56 GMT

Subscribe to the Stylus Scoop newsletter for helpful XML tips and tutorials.
Email
First Name
Last Name
Company

Download Stylus Studio 6 XML Enterprise Edition

Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.