473,387 Members | 1,624 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,387 software developers and data experts.

xml schema: rule between atribute value in one element

I need know how define xml schema for this xml fragment:

<set name="person-id" value="secure-card"/>
<set name="person-id" value="thumb-print"/>

<set name="length-unit" value="inch"/>
<set name="length-unit" value="cm"/>

so if name="person-id", then value can contain only one of value
"secure-card","thumb-print".
if name="length-unit", then value can contain only one of value
"inch","cm"
Jul 20 '05 #1
2 1530
You can't define that in XML Schema. What you can do is define the
following:

<personID value="secure-card"/>
<personID value="thumb-print"/>
<lengthUnit value="inch"/>
<lengthUnit value="cm"/>

using the following schema:

<xs:element name="personID">

<xs:complexType>

<xs:attribute name="value" type="personAtt"/>

</xs:complexType>

</xs:element>

<xs:element name="lengthUnit">

<xs:complexType>

<xs:attribute name="value" type="lengthAtt"/>

</xs:complexType>

</xs:element>

<xs:simpleType name="personAtt">

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

<xs:enumeration value="secure-card"/>

<xs:enumeration value="thumb-print"/>

</xs:restriction>

</xs:simpleType>

<xs:simpleType name="lengthAtt">

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

<xs:enumeration value="inch"/>

<xs:enumeration value="cm"/>

</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
"ocelka" <oc****@ics.muni.cz> wrote in message
news:2b**************************@posting.google.c om...
I need know how define xml schema for this xml fragment:

<set name="person-id" value="secure-card"/>
<set name="person-id" value="thumb-print"/>

<set name="length-unit" value="inch"/>
<set name="length-unit" value="cm"/>

so if name="person-id", then value can contain only one of value
"secure-card","thumb-print".
if name="length-unit", then value can contain only one of value
"inch","cm"

Jul 20 '05 #2
To ht best of my knowledge -- I dont think XML Schema supports your
conditional kind of validation.

I suggest taking a look at an alternative way i.e. XML Schematron
(Conditional Constraints are supported). Or you could think in terms of
XSLT itself i.e. write an XSLT that will be used as a way to validate.
However I am not sure if the this would be worth in the effort in the
overall context of what you are trying to validate here.

Jul 20 '05 #3

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

Similar topics

0
by: Lewis G. Pringle, Jr. | last post by:
Folks: I have some XML text I'm tranforming from one schema to another. Both schemas have their own notion of 'address' (as well as many other contepts). XSL seems to be mainly suited to...
4
by: bibsoconner | last post by:
Hi, I hope someone can please help me. I'm having a lot of trouble with schema files in .NET. I have produced a very simple example that uses "include" to include other schema files. It all...
2
by: Frosty | last post by:
Howto make datagrid enforce rules of xml schema? Created xml schema in the designer. Constraints created there using the following <xs:simpleType name="zipcode"><xs:restriction...
2
by: mrc-1 | last post by:
Hi, i'd like to validate my XML file (see below) using XML Schema. Now my question: is it possible to limit the occurrence of the element b in the data element. I mean: data can contain up to...
5
by: Reuven Nisser | last post by:
Hi, How can I describe an XML like this: <X> <Y/> <Z/> <Y/> <Y/> </X>
5
by: j.tremlett | last post by:
Hi, I have read various articles on this and I have had a few suggestions but would like to know which is correct. I have an XML file with the element <root> Within <root> I can have a...
4
by: cmay | last post by:
I am beginning to wonder if it is not possible to get this working. I am trying to do: <root> <a/> <b/> <c/> </root>
1
by: Nichino | last post by:
Hello, I'm trying to define my first Xml Schema and have a problem. The XML I'd like to define through the Schema is the following one. Can you help me please? I don't know how to insert the 3...
9
by: mstilli | last post by:
Hi, I am trying to use schema for server side validation using xerces to catch the validation errors. validating this XML: <Content4> <textarea13></textarea13>...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...

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.