- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 19 Dec 2001 19:23:30 +0000
- To: "Arigapudi, Shyam" <Shyam.Arigapudi@ugs.com>
- CC: "'xmlschema-dev@w3.org'" <xmlschema-dev@w3.org>
Hi Shyam,
> I would like to restrict a string based on a pattern:
>                (The string cannot have the set:    ?:,'<>/*\|= and " )
> <xsd:element name="LayerName">
>                         <xsd:simpleType>
>                                 <xsd:restriction base="xsd:string">
>                                         <xsd:minLength value="1"/>
>                                         <xsd:maxLength value="255"/>
>                                         <xsd:pattern
> value="[^?:,'/\\\*"><|=]"/>  <!--Need suggestion here -->
>                                 </xsd:restriction>
>                         </xsd:simpleType>
> </xsd:element>
That looks fine (though I think the * has no meaning in a character
group, so you don't have to escape it) - the only thing you're missing
is a + or * or something after the character range to enable the
pattern to match strings with more than one character in them:
  <xs:pattern value="[^?:,'/\\*"><|=]+" />
Or if you want, you could specify the number of allowable characters
in the pattern as well as through the minLength/maxLength facets:
  <xs:pattern value="[^?:,'/\\*"><|=]{1,255}" />
(BTW, I wouldn't get rid of the minLength/maxLength facets even if you
did that - they would enable some level of validation even from schema
processors that don't understand regular expressions.)
If you want to ban all punctuation, you could more simply use:
  <xs:pattern value="\P{P}{1,255}" />
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 19 December 2001 14:23:32 UTC