473,387 Members | 1,891 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.

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="JohnPerson", "JuliePerson", 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 1647
* 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****@hoehrmann.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...@hoehrmann.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...@hoehrmann.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*********@gmail.comwrote in message
news:55**********************************@34g2000h sh.googlegroups.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="JohnPerson", "JuliePerson", 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
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...
2
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...
7
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
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...
3
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...
2
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"...
6
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...
2
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...
0
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...
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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.