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

Re: Whitespace and patterns

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 16 Jan 2002 12:19:27 +0000
Message-ID: <124790909507.20020116121927@jenitennison.com>
To: Mike_Leditschke@nemmco.com.au
CC: xmlschema-dev@w3.org
Hi Michael,

> If I have the following type definition
>   <xsd:simpleType name="Fred">
>     <xsd:restriction base="xsd:string">
>       <xsd:pattern value="[\p{L}\p{N}\s]{1,30}"/>
>     </xsd:restriction>
>   </xsd:simpleType>
>   <xsd:element name="Fred" type=""Fred"/>
> Would a single space be legitimate content for Fred?, i.e.
> <Fred> </Fred>
> What I am trying to say is that any mixture of letters, numbers and
> whitespace from 1to 30 characters is allowed.
> XMLSpy says "the value does not match facet" but I'm struggling to
> see why.

Yes, it should be OK. Xerces C++ validates it OK.

If you just want to constrain the length of the string, it's a better
idea to use the min/max facets instead, I think:

  <xsd:simpleType name="Fred">
    <xsd:restriction base="xsd:string">
      <xsd:minLength value="1" />
      <xsd:maxLength value="30" />

Or you could try using:


instead - see if XML Spy can manage that any better.


Jeni Tennison
Received on Wednesday, 16 January 2002 07:19:32 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:54 UTC