473,378 Members | 1,478 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,378 software developers and data experts.

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

Similar topics

1
by: Ron Rohrssen | last post by:
I've been working on learning XML schemas and trying to make use of the MS classes for validating data against a schema. So, I've been trying to work through some simple schemas and instances....
9
by: Rob Mayo | last post by:
I have a bunch of XSD files in my assembly as embedded content that are read out via reflection and streams. My app creates the XML on the fly, and I want to validate it using the schema files...
1
by: John Smith | last post by:
Ok, I have 2 xml files that are really similar. They have the exact same structure exept that in one XML some element are required and in the other they are simply absent from the xml. Problem...
0
by: SHC | last post by:
Hi all, I have a VC++ .NET 2003 - Windows XP Pro PC. I created a Win32 console application in my VC++ .NET 2003 and copied validateDOM.cpp, books.xml and books.xsd (see the attached files below)...
10
by: Mike Logan | last post by:
I am using the "contract first" design methodology. Contract First is design the WSDL first then design the server and client. However I must design my XSD/XML Schema before anything. I am...
2
by: Doru Roman | last post by:
Hi, I use C# to validate an XML document. It issues error messages and I do not understand why. Here is the XML document: <bookstore xmlns="http://tempuri.org/books.xsd"> <book...
1
by: Confused XML hacker | last post by:
My application needs to be able to parse and validate either a DTD or schema based document without knowing in advance which form of grammar a document is using. (New documents presented to my...
4
by: LurfysMa | last post by:
I could use some help with a table design problem. I have an electronic flashcard program. Actually, several of them. They each rely on a utility program to keep track of the usage statistics....
0
by: Marc Scheuner | last post by:
Folks, I'm faced with a dilemma here - I have an XML document and for part of it, I have an XSD schema to validate it - but not for the rest of it. Can I still validate at least part of the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.