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" />
    </xsd:restriction>
  </xsd:simpleType>

Or you could try using:

  (\p{L}|\p{N}|\s)+

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

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 16 January 2002 07:19:32 GMT

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