473,729 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1756
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
1446
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. But, the parser inside of Visual Studio seems to frequently validate against a cached version of the schema. Occassionally I have an XML file that won't validate
9
2926
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 embedded in my assembly. Unfortunately, my problem is that every element is coming up invalid. Here is the code: Public Sub Validate(ByVal XmlText As String)Dim strmXML As New System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(XmlText))Dim...
1
1488
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 is in they are similar at 90% what I was looking for is a way to validate and say what "case" I want to test. For exemple in my XSD I somehow specify what apply to what and in the XML or simply at validation time I specify wich case I want to test.
0
4588
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) from Microfost MSDN Library for my project "validateXML". When I did "Build" on my project, I got the following fatal error C1010: c:\Documents and Settings\SHC\My Documents\Visual Studio Projects\valoidateDOM\valoidateDOM.cpp(273): fatal error...
10
1983
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 developing my schema now. I have a version on my schema. However once I start the server side code, how is the server now that the right "complexType" is being passed? What happens if this complexType my web service consumes needs to be...
2
2854
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 genre="novel" style="hardcover">
1
2218
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 system are schema based while the older ones are DTD - conversion is not an option as these document represent legally binding contracts and they must be processed as is). In the .Net 1.1 version of my code I used a XmlValidatingReader instance...
4
1682
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. After each practice session, the utility program tells the flashcard program which items were learned and whihc need more practice. The drill stats are trracked by 3 indices: user, subject, and item.
0
2650
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 XML document? I was hoping to use the XmlDocument.Validate(ValidationEventHandler, XmlNode) method for that - doesn't seem to work...
0
8921
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
9427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9202
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4528
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4796
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2683
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2165
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.