473,399 Members | 4,177 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,399 software developers and data experts.

validating xml defined by DTD - ignore node sequence

I want to bypass the dtd validation that child elements must appear in
a certain order ...

In a DTD child elements that are defined and seperated by commas they
must appear in the same sequence in an xml file in order for the xml to
be valid ...

eg if the dtd defines an element Parent with two child nodes
<!ELEMENT Parent (a, b)>

Then the following xml is valid

<Parent>
<a>data</a>
<b>data</b>
</Parent>

but the following xml

<Parent>
<b>data</b>
<a>data</a>
</Parent>

is invalid ...
Does anyone know of any ways to get around this issue ??? I have
developed an application that generates xml but the child nodes aren't
created in the same order as specified in the dtd and I want to
validate the xml document ...

I am currently using the XMLReader class to try to validate the xml
..Net framework 2.0

XmlReaderSettings settings = new XmlReaderSettings();
settings.ProhibitDtd = false;
settings.ValidationType = ValidationType.DTD;
settings.ValidationEventHandler += new
ValidationEventHandler(ValidationCallBack);
settings.CheckCharacters = false;
settings.DtdValidate = true;
settings.IgnoreValidationWarnings = true;

XmlReader reader = XmlReader.Create(_filename, settings);

while (reader.Read()) ;

Many Thanks

Nov 12 '05 #1
3 2808


ai********@gmail.com wrote:

I have
developed an application that generates xml but the child nodes aren't
created in the same order as specified in the dtd and I want to
validate the xml document ...


A DTD defines a grammar for a class of XML documents and validation is
supposed to check that an XML document instance complies with the DTD.
What would be the point of validation if the validator would claim the
document is valid but anyone wanting to make some exceptions could do that?
You would need a different DTD or a schema tailored to your needs and
then you could validate against your schema.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #2
Thanks Martin for your remarks but the main question is still without
an answer. Is it possible to do this?

best regards

Gawel

Nov 12 '05 #3


pa**********@gmail.com wrote:
Thanks Martin for your remarks but the main question is still without
an answer. Is it possible to do this?


The answer was and is that validation against a DTD is well defined and
not designed to allow anyone to make exceptions. If you cannot create
XML complying with a DTD then there is nothing in the validation process
you can change to nevertheless get the result "valid". You need to write
your own schema then with the desired grammar/structure and validate
against that.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Nov 12 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Iain | last post by:
I've got a system which takes an XML file, translates it into an update gram and then loads it into my database with SQLXML3 (all in dot net). But it's fragile. And the SQLXML 3 error reporting...
4
by: Tomas Rivas | last post by:
I am trying to validate an xml file and schema and when I am trying to validate I am getting the following error. I have been trying to come out with a solution but I have failed so far. The...
1
by: Andy | last post by:
I am having some trouble validating XML using the XmlValidatingReader. I have created some xml and used the visual studio to generate the schema. So I am confident that the xml and schema match. ...
0
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852...
4
by: Jonas Bush | last post by:
I've got the some code to try and validate some xml. Against my schema, the "Good" xml (below) produces a couple of warnings, which I don't care about. The "Bad" xml (also below), produces warnings...
4
by: Labm1ce | last post by:
' First create Xml document Dim oXmlDocument As New System.Xml.XmlDocument oXmlDocument.LoadXml("<Trees><Oak TreeType=""deciduous""></Oak></Trees>") oXmlDocument.Save("Trees.xml") ' .NET save...
2
by: mehuls | last post by:
I have an A.xml file which I am trying to validate with an A.xsd file. Hi All, A.xsd file inturn imports B.xsd and C.xsd. In A.xsd I have an element named "Account". Account is of type...
0
by: Patrick Brunmayr | last post by:
Hello I have a big Problem with validating a Soap Envelope. I have downloaded the xsd for a soap envelope from http://schemas.xmlsoap.org/soap/envelope/ The validation succeeds as lonng as i...
4
by: agda.karlberg | last post by:
Hello, I need to remove the DTD reference from an xml document, the reason for this is that we want to validate against a schema instead (which we have locally). It takes up to a minute to fetch...
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:
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...
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
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,...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.