473,657 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

xsd restriction

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:simpleTy pe name="StateType ">
<xsd:union>
<xsd:simpleType >
<xsd:restrictio n base="xsd:strin g">
<xsd:pattern value="[a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d" />
</xsd:restriction >
</xsd:simpleType>
<xsd:simpleType >
<xsd:restrictio n base="b:usState ">
</xsd:restriction >
</xsd:simpleType>
</xsd:union>
</xsd:simpleType>
<xsd:simpleTy pe name="usState">
<xsd:restrictio n base="xsd:NMTOK EN">
<xsd:enumeratio n value="AL"/>
<!—and all of other states up to: à
<xsd:enumeratio n 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!
Jul 20 '05 #1
1 4536
"Ed Slen" <ed******@yahoo .com> wrote in message news:53******** *************** ***@posting.goo gle.com...
<xsd:simpleTy pe name="StateType "> : : <xsd:restrictio n base="b:usState "> : : <xsd:simpleTy pe 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:StateTy pe" /> <!-- 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
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1301
by: c_capatana | last post by:
i have 2 abstract type defined: <xs:complexType name="InputHeaderType" id="InputHeaderType" abstract="false"> <xs:complexContent> <xs:restriction base="xs:anyType"> <xs:sequence/> <xs:attribute name="InputField" type="sg:InputFieldType" use="required"/> <xs:attribute name="keyfield" type="sg:KeyfieldType"
1
505
by: hre1 | last post by:
hello stan, thank you very much for your fast replay! your solution will help to solve my problem. but i try to understand !why! sqc and xmlspy produce this messages: SQC means:TYPE REFINEMENT ERROR (content type incompatible with the content type of the basetype) and
3
4030
by: nicolaspujol | last post by:
Hi, wondering if anybody could help me figure how to. in schema, restrict the list of tokens I may have as an attribute value. For example <xs:complexType name="customer"> <xs:sequence> <xs:element name="firstname" type="xs:string"/> </xs:sequence> <xs:attribute name="life" use="optional"> <xs:simpleType>
3
1729
by: Brett Gerhardi | last post by:
Hi all, can anyone explain why the following isn't valid? <?xml version="1.0" encoding="UTF-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified"> <xsd:complexType name="ct1"> <xsd:attribute name="a1" type="xsd:string" use="required"/> </xsd:complexType> <xsd:complexType name="ct2"> <xsd:complexContent>
0
1572
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema' referenced in this document. The value for the 'base' attribute is invalid - 'xsd:string' is an invalid value for the 'base' attribute. An error occured at the file:///C:Program Files/Microsoft Visual Studio .NET 2003...
5
1663
by: bclark76 | last post by:
I am getting a strange error, maybe someone knows why it is occurring.. I get the following error when I try to validate Untitled8.xml in Altova XMLSPY: Validation error in another file: Untitled3.xsd The message in XMLSPY in Untitled3.xsd is: The file is not valid: The content model of complex type { no name } is not a valid restriction of the content model of complex type 'Condiment_Type'
1
1929
by: brucepickford001 | last post by:
Hi, I have a not simple problem. I want the following XML to be schema valid <PopulationDemographic> <PersonName>Joe Blogs</PersonName> <Age>2</Age> <Category>baby</Category> </PopulationDemographic>
6
4269
by: burkley | last post by:
In XML Schema, is it possible to derive a complex type via restriction and have the new derived type be in a different namespace than the original base type? I've banged on this for 2 days now and I'm starting to think the answer is no. I've searched this group and have not seen anything discussing this. the base type. All values of the restricted type are also valid according to the base type".
1
4050
by: executeinc | last post by:
Could you some help to define 1. An element with restriction on it's base type (xs:string), limiting maxlength 2. That element also needs two attributes defined on it. Simple restriction is easy: <xs:element name="kirk" minOccurs="0" maxOccurs="1"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:maxLength value="2"/>
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7333
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
1620
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.