Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: regex help

From: Xan Gregg <xan.gregg@---.--->
To: "Michael Kay" <mike@--------.--->
Date: 1/3/2007 10:46:00 AM
I think Michael's list option won't work because the quoted string  
items can contain whitespace.  The all-in-one pattern requires  
trailing whitespace, so I offer the following derivative which doesn't:

   <xs:pattern value='("[^"]*"(\s+"[^"]*")*)?'/>

The final '?' is to allow the empty list (no items). Remove it if  
that is not desired.

xan

On Jan 3, 2007, at 2:57 PM, Michael Kay wrote:

>
> 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>
>
> ...
>
>> -----Original Message-----
>> From: xmlschema-dev-request@w...
>>
>> ...
>>
>> 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?
>>
>
>


From petexmldev@t... Thu Jan 04 09:40:04 2007
Received: from maggie.w3.org ([193.51


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent