473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Conditionally validate XML

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
4 1472
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Quinten Carlson | last post by:
Is there a way to conditionally define a function in php? I'm trying to run a php page 10 times using the include statement, but I get an error because my function is already defined. The docs...
2
by: Hans-Michael Rupp | last post by:
Hello! I need to a assign a node(-set) conditionally to a varialbe like: <xsl:variable name="foo"> <xsl:if test="$bar=''"> <!-- how can I access a node here ?--> </xsl:if> <xsl:if...
3
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I...
10
by: SueB | last post by:
I currently have a 'mail-merge' process in my Access db project. It generates custom filled out Award Certificates based on an SQL SELECT statement in a VBA routine invoked by clicking on a...
2
by: Jens Weiermann | last post by:
Hi, I need to conditionally disable a html (not web forms) button control. The condition is to be evaluated server-side. What is the smartest way to do this? I'm now using a literal server-side...
2
by: Felix | last post by:
Hello, I use a #define like WITH_MYSTUFF to conditionally compile code within #ifdef WITH_MYSTUFF. I would now like the same define to conditionally link with a library. In the linker settings...
4
by: bubulle | last post by:
Hi, all. Here is my problem: Let's say i have table1 with columns a,b,c and table2 with cols x,y,z. Some of columns contain the same type of data from one table to the other, but others are...
1
by: kaens | last post by:
So, I have a class that has to retrieve some data from either xml or an sql database. This isn't a problem, but I was thinking "hey, it would be cool if I could just not define the functions for...
3
by: yasmin | last post by:
I am trying to conditionally compile macros in my c++ program. I want to simply be able to use the macro name without enclosing it in #ifdef-#endif each time. How can I enclose the macro definition...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.