Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > xsd restriction

Reply
Thread Tools

xsd restriction

 
 
Ed Slen
Guest
Posts: n/a
 
      06-25-2003
Hi, Guys!
Have a question about xsd restriction:

I am having an element "state" and it could be US state (Which is
easy) or Canadian postal code which is easy too (both rules are
working separately), but I am having difficulties combining this two
rules together.
Here is what I have tried:

<xsd:simpleType name="StateType">
<xsd:union>
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsdattern value="[a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType>
<xsd:restriction base="b:usState">
</xsd:restriction>
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>


<xsd:simpleType name="usState">
<xsd:restriction base="xsd:NMTOKEN">
<xsd:enumeration value="AL"/>
<!—and all of other states up to: à
<xsd:enumeration value="WY"/>
</xsd:restriction>
</xsd:simpleType>

this gives enumeration error if I use Canadian postal code.

Please, help!
What am I doing wrong?

Thanks in advance!
 
Reply With Quote
 
 
 
 
Derek Harmon
Guest
Posts: n/a
 
      06-25-2003
"Ed Slen" <(E-Mail Removed)> wrote in message news:(E-Mail Removed) om...
> <xsd:simpleType name="StateType">

: :
> <xsd:restriction base="b:usState">

: :
> <xsd:simpleType name="usState">

: :
> this gives enumeration error if I use Canadian postal code.


This works for me, assuming the prefix b is defined as your targetNamespace.

Your XML Schema snippet did not include an element declaration, I'd just check
for what might be an obvious snag:

<xsd:element name="location" type="b:StateType" /> <!-- OK -->
<xsd:element name="location" type="b:usState" /> <!-- Not the Union type: Bug -->

You would get an enumeration error if the element where the Canadian postal
code appears is making reference to the b:usState type instead of the union
type, b:StateType.


Derek Harmon


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XSD type derived via restriction in same namespace as restricted type? burkley@gmail.com XML 7 09-18-2007 01:51 PM
Restriction on attributes in XSD vincente13@gmail.com XML 1 06-14-2006 11:57 AM
XSD restriction SP XML 0 09-26-2005 03:49 PM
[XSD] derivation by restriction Lars Geldner XML 4 01-07-2005 12:14 PM
XSD: Question on derivation-ok-restriction.5.4.2 Cat XML 3 06-25-2004 11:18 AM



Advertisments