W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2007

Re: regex help

From: Boris Kolpackov <boris@codesynthesis.com>
Date: Fri, 5 Jan 2007 10:19:28 +0200
To: "Watkins, Bill" <bill.watkins@boeing.com>
Cc: xmlschema-dev@w3.org, "Tsao, Scott" <scott.tsao@boeing.com>
Message-ID: <20070105081928.GA14525@karelia>

Hi Bill,

Watkins, Bill <bill.watkins@boeing.com> writes:

> 	<QuotedStringList>
> 		"your dog.my_dog" "my_cat$your_cat"
> 		"their_rat"
> 	</QuotedStringList>
>
> [...]
>
> 	<xs:simpleType name="QUOTEDNAME_TYPE">
> 		<xs:restriction base="xs:string">
> 			<xs:pattern value='\s*"\S([^"]|\s)+\S"\s*'/>
> 		</xs:restriction>
> 	</xs:simpleType>
>
> 	<xs:simpleType name="QUOTEDNAMELIST_TYPE">
> 		<xs:list itemType="QUOTEDNAME_TYPE"/>
> 	</xs:simpleType>

The list-based approach won't works since you can have whitespaces inside
list values. In the example above your list will be chopped up as follows:
'"your' 'dog.my_dog"' '"my_cat$your_cat"' '"their_rat"'.


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

This one won't work since it expects at least one whitespace after a
quoted string, even the last one.


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

This one is almost there. The only thing you need to add is optional
whitespaces before the first quoted string and after the last (note
the newlines after <QuotedStringList> and before "your dog.my_dog"
as well as after "their_rat" and before </QuotedStringList> -- they
are part of the value):

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


hth,
-boris


-- 
Boris Kolpackov
Code Synthesis Tools CC
http://www.codesynthesis.com
Open-Source, Cross-Platform C++ XML Data Binding
Received on Friday, 5 January 2007 08:36:34 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:57 GMT