[XML Schema] Attributes

K

kelvSYC

Is it possible to make an attribute required, optional, or forbidden
depending on the value of another attribute? How about changing
element content based on an attribute?
 
S

Steve Jorgensen

Is it possible to make an attribute required, optional, or forbidden
depending on the value of another attribute? How about changing
element content based on an attribute?

Sure - just not with W3C XML Schema <g>. You can supplement XML Schema with
Schematron or just write a custom XSL transform that produces output
describing any rules if finds to be broken.
 
K

kelvSYC

Steve said:
Sure - just not with W3C XML Schema <g>. You can supplement XML Schema with
Schematron or just write a custom XSL transform that produces output
describing any rules if finds to be broken.

What about other schema languages? Does RELAX NG, for example, have
this ability?
 
S

Steve Jorgensen

What about other schema languages? Does RELAX NG, for example, have
this ability?

I'm not a RELAX NG user because it isn't supported for what I need, but I am
led to understand that it cannot do things like that, and that Scehamtron is
pretty much the only schema language that can.

You can embed Schematron in either XML Schema or in RELAX NG, and most decent
XML editors can use the embedded Schematron if you tell them to (I use
<oXygen/> for this).

I'm starting to see, though, that even though it's a separate file and a bit
harder to keep clean and legible, using a custom xsl file might be the better
way to go. For one thing, you can use XSLT 2.0 without worrying about whether
your editor supports XSLT 2.0 functionality in Schematron, and for another
thing, you don't have to figure out how you're going to use Schematron to
validate documents in an application using, say, MSXML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,001
Messages
2,570,250
Members
46,848
Latest member
Graciela Mitchell

Latest Threads

Top