473,239 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,239 software developers and data experts.

XML Schema - How to do a key-value map with 2 enumerations?

In my schema I have 2 enumerations, let's say, country description and
country code, and I want to use them so I can map each country
description to its precise country code (and no other).
So far I've seen I can define both keys for description and code, but
my XMLs validate even if I choose a wrong pair:

Here are my both enumerations (abbreviated)
<xs:simpleType name="COUNTRYCODE">
<xs:restriction base="xs:int">
<xs:enumeration value="4"/>
<xs:enumeration value="8"/>
<xs:enumeration value="958"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="COUNTRYDESC">
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
<xs:enumeration value="Afghanistan"/>
<xs:enumeration value="Albania"/>
<xs:enumeration value="Germany"/>
</xs:restriction>
</xs:simpleType>

And I use the "country" element as follows:

<xs:element name="COUNTRY">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="COUNTRYDESC"/>
<xs:element name="value" type="COUNTRYCODE"/>
</xs:sequence>
</xs:complexType>
</xs:element>

How should I define the map and the keys, etc. so that something like
this validates:

<COUNTRY>
<COUNTRYDESC>Germany</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>

But this DOES NOT validate (as it's a wrong description-code pair):

<COUNTRY>
<COUNTRYDESC>Afghanistan</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>

I'll be very grateful for any help!
Jul 20 '05 #1
1 4356
Hi Joyce,

You can't specify this restriction in XML Schema. Have you considered doing
it this way:

<xs:simpleType name="countryDescCode">

<xs:restriction base="xs:string">

<xs:enumeration value="Afghanistan, 4"/>

<xs:enumeration value="Albania, 8" />

<xs:enumeration value="Germany, 958"/>

</xs:restriction>

</xs:simpleType>
--
Stan Kitsis
Program Manager, XML Technologies
Microsoft Corporation

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm

"Joyce" <jo*********@gmail.com> wrote in message
news:7b*************************@posting.google.co m...
In my schema I have 2 enumerations, let's say, country description and
country code, and I want to use them so I can map each country
description to its precise country code (and no other).
So far I've seen I can define both keys for description and code, but
my XMLs validate even if I choose a wrong pair:

Here are my both enumerations (abbreviated)
<xs:simpleType name="COUNTRYCODE">
<xs:restriction base="xs:int">
<xs:enumeration value="4"/>
<xs:enumeration value="8"/>
<xs:enumeration value="958"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="COUNTRYDESC">
<xs:restriction base="xs:string">
<xs:maxLength value="40"/>
<xs:enumeration value="Afghanistan"/>
<xs:enumeration value="Albania"/>
<xs:enumeration value="Germany"/>
</xs:restriction>
</xs:simpleType>

And I use the "country" element as follows:

<xs:element name="COUNTRY">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="COUNTRYDESC"/>
<xs:element name="value" type="COUNTRYCODE"/>
</xs:sequence>
</xs:complexType>
</xs:element>

How should I define the map and the keys, etc. so that something like
this validates:

<COUNTRY>
<COUNTRYDESC>Germany</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>

But this DOES NOT validate (as it's a wrong description-code pair):

<COUNTRY>
<COUNTRYDESC>Afghanistan</COUNTRYDESC>
<COUNTRYCODE>958</COUNTRYCODE>
</COUNTRY>

I'll be very grateful for any help!

Jul 20 '05 #2

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

Similar topics

0
by: Ognen Ivanovski | last post by:
Is the following constraint possible to be expressed with XML Schema (and how): Suppose we have a document in the form <car type="ford"> <part name="door"/> <part name="ashtray"/> </car>
0
by: Olaf Meyer | last post by:
I'm wondering if I can also express uniquness constraints on attributes of objects that I have referenced from somewhere else. To be a bit more precise here a short and simple XML document. The...
0
by: peterpeter | last post by:
Hi. There is a XML schema problem that I have with key/keyref: I have two complex (A and B) types which both inherit from a common base typ (Base). A refers B using a xs:IDREF element named...
0
by: johnsocs | last post by:
All I'm trying to write an xml schema for the following xml from the google web service api. In the schema I'm not sure how to describe the soapenv:encodingStyle attribute. Thanks. <?xml...
3
by: johnsocs | last post by:
All - I am very stuck on building a schema for the following xml message. I feel I'm very close as the message validates if I remove the...
4
by: Iain A. Mcleod | last post by:
Hi I'm stuck with the following schema validation problem in VS.NET 2003: I have two types of xml document and related schema: project and projectCollection. A projectcollection is just a set...
1
by: Mr. Almenares | last post by:
Hello: I’m trying to do a schema with recurrent structure for a Book like a Node can have many Nodes inside or One leave. So, the leaves have an attribute that is Identifier. My goal is define...
7
by: Robert Stearns | last post by:
I ran the following bit of SQL and my PRIMARY KEY wound up in schema SYSIBM called SQL.... not schema is3 called primary. The index registation did wind up there. Obviously there's something I...
6
by: Emma Middlebrook | last post by:
Hi there, I have created an XmlSchema to represent the tables in my database and I have specified a primary key for each of the tables. However, to be able to execute the following code: ...
0
by: icesign | last post by:
I know that the selector of these elements has a scope relative to the element being declared, but maybe there is a way to get beyond bounds of this scope or maybe just a way to extend base element?...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

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.