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