473,769 Members | 2,170 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

schema, attributes, interdependent restrictions


I'm trying to figure out if something is possible to specify and
constrain using a schema. I'll explain using an example.

sample xml:
<person name="John" age="32"/>
<person name="Julie" age="25"/>

In my schema, I'd love to be able to place different restrictions on
the attribute 'age' based on the value of 'name'... so in this
example, I might want to enforce that any entry where name="John"
includes an age attribute that falls between 30-39, and that Julie's
age value is 20-29.

What I tried to do, and is invalid, is define a JohnPerson and
JuliePerson element type, and then specify that I expected a list
(all) of elements having an element name="person" and
type="JohnPerso n", "JuliePerso n", etc... by the parser rejected that
with "Multiple elements with name 'person', with different types,
appear in the model group."

Any ideas?

Many thanks,
Marc
Jun 27 '08 #1
3 1676
* Marc Hebert wrote in comp.text.xml:
>I'm trying to figure out if something is possible to specify and
constrain using a schema. I'll explain using an example.

sample xml:
<person name="John" age="32"/>
<person name="Julie" age="25"/>

In my schema, I'd love to be able to place different restrictions on
the attribute 'age' based on the value of 'name'... so in this
example, I might want to enforce that any entry where name="John"
includes an age attribute that falls between 30-39, and that Julie's
age value is 20-29.
This is not possible with XML Schema 1.0. You could check out NVDL (with
multiple XML Schema schemas), RELAX NG, and Schematron (possibly XML
Schema with embedded Schematron), none of which will work in simple XML
Schema 1.0 implementations of course.
--
Björn Höhrmann · mailto:bj****@h oehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 27 '08 #2
On May 23, 7:43 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* Marc Hebert wrote in comp.text.xml:
I'm trying to figure out if something is possible to specify and
constrain using a schema. I'll explain using an example.
sample xml:
<person name="John" age="32"/>
<person name="Julie" age="25"/>
In my schema, I'd love to be able to place different restrictions on
the attribute 'age' based on the value of 'name'... so in this
example, I might want to enforce that any entry where name="John"
includes an age attribute that falls between 30-39, and that Julie's
age value is 20-29.

This is not possible with XML Schema 1.0. You could check out NVDL (with
multiple XML Schema schemas), RELAX NG, and Schematron (possibly XML
Schema with embedded Schematron), none of which will work in simple XML
Schema 1.0 implementations of course.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Thanks very much for that info, that saves me a few hours of trying to
do something impossible.

Marc
Jun 27 '08 #3
test
"Marc Hebert" <he*********@gm ail.comwrote in message
news:55******** *************** ***********@34g 2000hsh.googleg roups.com...
>
I'm trying to figure out if something is possible to specify and
constrain using a schema. I'll explain using an example.

sample xml:
<person name="John" age="32"/>
<person name="Julie" age="25"/>

In my schema, I'd love to be able to place different restrictions on
the attribute 'age' based on the value of 'name'... so in this
example, I might want to enforce that any entry where name="John"
includes an age attribute that falls between 30-39, and that Julie's
age value is 20-29.

What I tried to do, and is invalid, is define a JohnPerson and
JuliePerson element type, and then specify that I expected a list
(all) of elements having an element name="person" and
type="JohnPerso n", "JuliePerso n", etc... by the parser rejected that
with "Multiple elements with name 'person', with different types,
appear in the model group."

Any ideas?

Many thanks,
Marc

Jun 27 '08 #4

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

Similar topics

50
6377
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong def foo(self, data): self.attr1=data self.attr2.append(data) The initialization of attr1 is obviously OK, all instances of Father redefine it in the method foo. But the initialization of attr2 is wrong
2
1766
by: Victor | last post by:
I have a Schema with some elements which are "types" or objects, and some elements which correspond to instances of the types. How can I specify that a <locationInstance> must have an attribute "type" which equals any one of the "id" attributes of the <locationType>s? -- Victor CERN / NTNU
7
1851
by: Info 3000 | last post by:
Hello, I'm beginner in XML. I have just a little question : I understand that I can write : <Book> <Title> A nice day </Title> <Author> James Nicepen </Author> </Book>
1
1372
by: obsolete_5 | last post by:
is it possible? more specifically, a simple example: i want a 'table' element to have a sequence of 'entry' elements. i know you can use minOccur = maxOccur = x, to enforce table to have x entry elements in it. but this x value needs to be hardcoded in the schema.
3
2091
by: RugbyCoach | last post by:
I'm looking for a tool that can extract only the schema from a database in a form that can be used to generate that schema in another empty database. This is to facilitate our disaster recovery processes where we need the objects only, not the data, and need to replicate this to our disaster recovery site over the WAN. There are plenty of tools that can handle a single database, but does anyone know of any tools that could handle...
2
9235
by: Shailendra Batham | last post by:
Hello Gurus, I want to put some restrictions on my attribute tag in my XML Schema, anyone out there have any idea how to do that. here is my XML and the XML Schema <?xml version="1.0" encoding="utf-8"?> <Book ID="1000000000"> <Name>XML Basic</Name> <Comments>Whatever</Comments>
6
2589
by: Martin | last post by:
Hi, I have a xml file like the one below <?xml version="1.0" encoding="utf-8"?><e1 xmlns:e1="http://tempuri.org/Source1.xsd" e1:att1="1" e1:att2="2" e1:rest="345"/> If I try to create a schema for it with Visual Studio, I get the error "Failed to create a schema for this data file because:
2
2819
by: Chuck Bowling | last post by:
AIML Schema: http://209.168.21.76/CommunityStarterKit/Downloads/258.aspx I have a Schema (in the link above) that I've been trying to make work in VS2003 for a while now and just can't seem to get right. I didn't design the schema and to tell the truth, most of it is beyond my rudimentary understanding of XML. So far, the main problem I've run into is the simpleType below: <simpleType name="VariableName">
0
1330
by: ruediger | last post by:
Hi there, I want to set up an XML Schema for documents of the following structure: The <root> node contains - an optional <message> element with a text attribute, and - arbitrary further content. To make the parts unique, the top-level element of the further content
0
9579
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
10035
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...
0
9850
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
8862
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
7396
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
6662
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5436
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3551
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.