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

Conditionally validate XML

P: n/a
Hi there,

Would like to conditionally validate XML i.e.

If element <ElementAhas a particular value
then element <ElementBmust 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 <ElementAand
<ElementBand produce output based upon their values: This seems a bit
hokey.

Your thoughts would be appreciated

Lord0

Oct 19 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Lord0 wrote:
Would like to conditionally validate XML i.e.

If element <ElementAhas a particular value
then element <ElementBmust 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 <ElementAand
<ElementBand 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.
--

Martin Honnen
http://JavaScript.FAQTs.com/
Oct 19 '06 #2

P: n/a
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

Oct 19 '06 #3

P: n/a
Lord0 wrote:
Hi there,

Would like to conditionally validate XML i.e.

If element <ElementAhas a particular value
then element <ElementBmust 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 <ElementAand
<ElementBand 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....ve-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 !
Oct 19 '06 #4

P: n/a
Lord0 wrote:
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?
A list of implementations: http://www.schematron.com/links.html
// Magnus
Oct 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.