M
Marc Hebert
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
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