By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,496 Members | 1,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,496 IT Pros & Developers. It's quick & easy.

XML Schema "logic"?

P: n/a
I'm trying to discern whether XML Schema can do something like this:

Supposing the element has two attributes, id and value.

Now, if id = one value, say "number" vs. another value, say, "alpha",
can I write XML Schema that would limit the values of the attribute
"value" to
1, 2, or 3 if id is number vs. a, b, or c if id is alpha?

I'm trying to tell whether I have to resort to Schematron to do
something like this.

Thanks in advance,

Nov 16 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
If you want cross-constraints on separate values, XML schema doesn't do
that.

In schemas, the right answer would be to use two different kinds of
element rather than one with an ID attribute that toggles it between two
different value ranges. Attributes should be used for annotation to
enhance meaning, not to change meaning.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Nov 16 '06 #2

P: n/a
In schemas, the right answer would be to use two different kinds of
element rather than one with an ID attribute that toggles it between two
different value ranges. Attributes should be used for annotation to
enhance meaning, not to change meaning.
.... or, alternatively, two different attributes for the two different
value ranges on a single element.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Nov 16 '06 #3

P: n/a

Joseph Kesselman wrote:
If you want cross-constraints on separate values, XML schema doesn't do
that.

In schemas, the right answer would be to use two different kinds of
element rather than one with an ID attribute that toggles it between two
different value ranges. Attributes should be used for annotation to
enhance meaning, not to change meaning.

Thanks, Joe. I had the feeling that XML Schema doesn't supply that
functionality. Unfortunately, changing the schema (other to be more
restrictive for further validation to "business rules") is not an
option - the output has to conform to a set XML Schema.

Failing being able to do this in XML Schema, would using Schematron be
a viable strategy?

Nov 16 '06 #4

P: n/a
I haven't used Schematron, so I have no valid opinion. I'd probably
approach it via application code myself, just because I'm used to
rattling off SAX and DOM applications.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 17 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.