473,516 Members | 3,355 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlValidatingReader, XmlSchemaException extra elements error handling

I have a defined XML Schema, and XML documents containing data that I
validate against it. Periodically, I will have a data document that
will contain extra elements that are not part of my schema. The powers
that be have determined that this is acceptable.

I am looking for the best way to continue to validate my documents
against my schema, but ignore any errors dealing with extra elements.

My first thought is to use a XmlValidatingReader, and use a try/catch
block to catch any XmlSchemaException messages. If the message contains
one of the common exceptions that get raised when there is an extra
element (such as: The element 'XXXX' has invalid child element 'YYYY')
then I will ignore that error and continue on.

This seems like a bit of a hack, can anyone think of a better approach
to this problem?

Thanks
---
Matthew

Nov 12 '05 #1
2 1792
Hi Matthew,

You could take a look at using the <xs:any ...> schema element within your
schema. Have a look at your usual sources/helpfile for an explanation of the
namespace attribute for this schema element.

Cheers
Phil

"ma***************@gmail.com" wrote:
I have a defined XML Schema, and XML documents containing data that I
validate against it. Periodically, I will have a data document that
will contain extra elements that are not part of my schema. The powers
that be have determined that this is acceptable.

I am looking for the best way to continue to validate my documents
against my schema, but ignore any errors dealing with extra elements.

My first thought is to use a XmlValidatingReader, and use a try/catch
block to catch any XmlSchemaException messages. If the message contains
one of the common exceptions that get raised when there is an extra
element (such as: The element 'XXXX' has invalid child element 'YYYY')
then I will ignore that error and continue on.

This seems like a bit of a hack, can anyone think of a better approach
to this problem?

Thanks
---
Matthew


Nov 12 '05 #2
Ahh, very nice. That solves my immediate problem, but introduces other
questions I will need to ponder.

Thank you very much
---
Matthew

Nov 12 '05 #3

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

Similar topics

1
2834
by: Dmitry Martynov | last post by:
Hi I have a question whether XmlValidatingReader doesn't check keyref constrain (the same with key constraint) or I do smth wrong. I have the following schema <?xml version="1.0" encoding="utf-8"?> <xs:schema id="module" targetNamespace="http://tempuri.org/module.xsd"
4
497
by: Larry | last post by:
I believe the .Net XmlValidatingReader should fail when validating XML that contains a ComplexType element with white space when the ComplexType element has the mixed attribute set to false in the XSD used for validation. XSD fragment: <xs:element name="TRSellerBuyerData"> <xs:complexType mixed="false"> <xs:sequence>
4
1581
by: Adam Smith | last post by:
XmlValidatingReader too sensitive? I have the following schemas (simplified) and xml file which validate fine in xmlspy, but blow up in xmlvalidatingreader with: 'The 'Hierarchy' element is not declared. An error occurred'. Any help appreciated. To give a brief explanation of what I'm trying to do, the schema 1 is a
0
4661
by: Harold Putman | last post by:
The XmlValidatingReader seems to have changed drastically in .Net Frameworks 1.0 SP3 and beyond with regards to validating XML files that are XML Schemas. Consider the following code: --- class ValidatingSchema { static void Main(string args)
2
1471
by: Mike Bridge | last post by:
Hi- I've created an XHTML extension module which validates correctly using the W3C online schema validator, but fails when I use the .net 1.1 validator. It seems to be choking on an included W3C file: http://www.w3.org/MarkUp/SCHEMA/xhtml-notations-1.xsd The problem seems to be on this line: <xs:notation name="cdata"...
3
2535
by: jason | last post by:
i am using an XMLValidatingReader in a manner similar to the following code example: string sReturn = ""; XmlValidatingReader oXML = new XmlValidatingReader(sXMLString, XmlNodeType.Document, null); oXML.Schemas.Add("", sSchemaURL); oXML.ValidationType = ValidationType.Schema; oXML.ValidationEventHandler += new
5
1391
by: Geoff | last post by:
I am using an XMLValidatingReader to validate an XML file received via a web service. I want to verify that the incoming file matches the XML schema. When testing the validation routine, the XMLValidatingReader correctly flags mis-matched tags such as <abc>some content</xyz> but does not catch other errors. For example, it doesn't catch tags...
1
2095
by: Bernhard Felkel | last post by:
I have troubles validating XML files with key/keyref constraints. Here´s my schema: <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:transNS="http://Festo.Common.Translation" xmlns="http://Festo.Common.Translation" targetNamespace="http://Festo.Common.Translation"...
2
7139
by: josh | last post by:
Hi, I am trying to validate cXML documents against cXML.dtd using the XmlValidatingReader. If I set the XMLValidatingReader's ValidatingType to ValidationType.DTD, I get the following System.Xml.Schema.XmlSchemaException: "The parameter entity replacement text must nest properly within markup
0
7182
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7405
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. ...
0
7574
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7547
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5106
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4769
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...
0
3265
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...
0
1620
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
0
487
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...

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.