467,142 Members | 1,264 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,142 developers. It's quick & easy.

Validate subsets of XML document using different schema?

I *think* I need to be able to validate subsets of an XML document
using different schema. The functionality I'm trying to implement is
this.

a) External suppliers produce an XML document containing multiple User
records. The external supplier validates this entire document using
schema 1. This document is then uploaded to our system.

b) Our system then checks that the supplied document "looks okay",
minimally, using Schema 2. Schema 2 just looks for a <userselement
containing one or more <userelements, each of which which may contain
"anything". If the document fails this validation the external supplier
receives a message like "This does not look like a valid User records
document" and processing stops.

c) Assuming the record passed b) above then each individual <user>
record is extracted and validated using Schema 3. Allowing us to say
something like "User record 1 was valid, User record 2 was invalid:
Name missing" etc.

## Sample XML

1,2 <users>
1,2,3 <user>
1 ,3 <name/>
1 ,3 <phone/>
1 ,3 <email/>
1,2,3 </user>
1,2,3 <user>
1 ,3 <name/>
1 ,3 <phone/>
1 ,3 <email/>
1,2,3 </user>
1,2,3 <user>
1 ,3 <name/>
1 ,3 <phone/>
1 ,3 <email/>
1,2,3 </user>
1,2 </users>

1 = validated with Schema 1 (external supplier)
2 = validated with Schema 2 (to check that file "looks okay")
3 = validated with Schema 3 (for each <user>)

## /Sample XML

I know I could, using string manipulations, chop up the document,
extract the parts I need, concatenate different Schema declarations and
validate but this seems inelegant.

So is the above possible in a more XML centric manner? Maybe I should
change my approach?

Cheers

Lawrence

Nov 23 '06 #1
  • viewed: 1491
Share:
3 Replies
Lord0 schrieb:
I *think* I need to be able to validate subsets of an XML document
using different schema. The functionality I'm trying to implement is
this.

a) External suppliers produce an XML document containing multiple User
records. The external supplier validates this entire document using
schema 1. This document is then uploaded to our system.

b) Our system then checks that the supplied document "looks okay",
minimally, using Schema 2. Schema 2 just looks for a <userselement
containing one or more <userelements, each of which which may contain
"anything". If the document fails this validation the external supplier
receives a message like "This does not look like a valid User records
document" and processing stops.

c) Assuming the record passed b) above then each individual <user>
record is extracted and validated using Schema 3. Allowing us to say
something like "User record 1 was valid, User record 2 was invalid:
Name missing" etc.
My aren't the requirements for b) and c) in schema 1?
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Nov 23 '06 #2
My aren't the requirements for b) and c) in schema 1?
--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)

Schema 1 is the schema supplied to the external user which describes,
and requires, ALL elements from the whole instance to be present.

I dont think I can put the requirements for b) and c) in Schema 1 as
they describe subsets of the instance document.

i.e. The requirement for b) is that the instance document should
contain a <userselement containing one or more <userelements EACH
OF WHICH can contain anything. But Schema 1 looks for a <userselement
containing one or more <userelements EACH OF WHICH has a <name>,
<phoneand <email>

Does this make it clearer?

Nov 23 '06 #3
Have a look at NVDL (Namespace-based Validation and Dispatching
Language). There are already a few implementations available, we just
released last week one called oNVDL. oNVDL is available also from
oXygen XML Editor version 8 so you can easily develope NVDL scripts and
test your documents from within oXygen XML Editor.

NVDL http://www.jtc1sc34.org/repository/0694c.htm
oNVDL http://www.oxygenxml.com/onvdl.html
oXygen XML Editor http://www.oxygenxml.com

Basically the idea is that you describe what fragments from the XML
document will be validated with what schema. Supported schema types in
oNVDL are XML Schema, Relax NG and Schematron.

Best Regards,
George
---------------------------------------------------------------------
George Cristian Bina
<oXygen/XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

Nov 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Doru Roman | last post: by
reply views Thread by Marc Scheuner | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.