W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2004

RE: Allowing only a fixed length or empty for an element

From: Michael Kay <mike@saxonica.com>
Date: Wed, 6 Oct 2004 21:58:55 +0100
To: "'Wilde Rebecca L SSgt HQ SSG/STS'" <Rebecca.Wilde@Gunter.AF.mil>, <xmlschema-dev@w3.org>
Message-Id: <E1CFIsH-0003ld-00@ukmail1.eechost.net>
I don't know off-hand whether a quantifier of {0} is allowed, but it's
certainly unconventional. What's wrong with
pattern value="([0-9]{4})?"
Michael Kay


From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Wilde Rebecca L SSgt HQ SSG/STS
Sent: 06 October 2004 21:04
To: xmlschema-dev@w3.org
Subject: Allowing only a fixed length or empty for an element


I am trying to create a type that allows either a four position numeric or
else must be an empty tag. 

I.E. I want <Tag/> or <Tag>0045</Tag> to be valid, but I don't want
<Tag>45</Tag> to be validated. 

I've come up with the following to try and do this: 

<xs:element name="Tag" type="TagType"/> 
<xs:simpleType name="TagType"> 
  <xs:restriction base="xs:string"> 
    <xs:pattern value="([0-9]{4})|[ ]{0}"/> 

I'm using XMLSpy to help me as an editor for creating most of my work and
validating it.  The above will allow me to validate/not validate as I
desired, but when others try to use XMLSpy to validate against it as an
empty tag, it comes back invalid.  

Is this a problem with XMLSpy, or is there a different way I should be
trying to accomplish my goal? 

Thank you! 
Received on Wednesday, 6 October 2004 20:59:01 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:06 UTC