Conditionally validate XML

L

Lord0

Hi there,

Would like to conditionally validate XML i.e.

If element <ElementA> has a particular value
then element <ElementB> must have a particular value

I'm pretty sure I can't do this this with a Schema.....

I know I could use an XSLT to check the values of <ElementA> and
<ElementB> and produce output based upon their values: This seems a bit
hokey.

Your thoughts would be appreciated

Lord0
 
M

Martin Honnen

Lord0 said:
Would like to conditionally validate XML i.e.

If element <ElementA> has a particular value
then element <ElementB> must have a particular value

I'm pretty sure I can't do this this with a Schema.....

The W3C XSD schema language can define some constraints, it for instance
has the xs:key and xs:keyRef elements to model keys and referential
integrity (e.g. ElementB having as its contents the contents of the
ElementA elsewhere).
Or you can extend or restrict types and that way model constraints
between elements.
I know I could use an XSLT to check the values of <ElementA> and
<ElementB> and produce output based upon their values: This seems a bit
hokey.

You might want to look into the Schematron language that allows you to
write assertions as XSLT match patterns and is then usually implemented
by generating and executing XSLT stylesheets with an XSLT processor.
 
L

Lord0

You might want to look into the Schematron language that allows you to
write assertions as XSLT match patterns and is then usually implemented
by generating and executing XSLT stylesheets with an XSLT processor.

Yes, I've just discovered Schematron (since my initial post)

Can you point me in the direction of any articles on how to get it
set-up? I have found plenty of articles which show you examples of
Schematron "schema": these seem reasonably obvious as I am familar with
XPath and XSLT.

However I can find no articles which say, for example, "you must have
X, Y, Z installed, the following system variables set" etc etc

Cheers

Lord0
 
P

Philippe Poulard

Lord0 said:
Hi there,

Would like to conditionally validate XML i.e.

If element <ElementA> has a particular value
then element <ElementB> must have a particular value

I'm pretty sure I can't do this this with a Schema.....

I know I could use an XSLT to check the values of <ElementA> and
<ElementB> and produce output based upon their values: This seems a bit
hokey.

Your thoughts would be appreciated

Lord0

You can express more assertions with the Active Schema Language than
existing schemata technologies (DTD, W3C XML Schema, Relax NG) :

http://disc.inria.fr/perso/philippe.poulard/xml/active-tags/active-schema/active-schema.html

You will be able to build active content models, that is to say content
models that may vary dynamically according to what you encounter in your
XML input, or any condition suitable to your application.

Here is the implementation :
http://reflex.gforge.inria.fr/

and an example that perform something like you expect :
http://reflex.gforge.inria.fr/tutorial.html#N801359

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
 

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

Forum statistics

Threads
474,006
Messages
2,570,265
Members
46,860
Latest member
JeremiahCo

Latest Threads

Top