473,612 Members | 2,129 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XmlValidatingRe ader, XmlSchemaExcept ion 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 XmlValidatingRe ader, and use a try/catch
block to catch any XmlSchemaExcept ion 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 1797
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 XmlValidatingRe ader, and use a try/catch
block to catch any XmlSchemaExcept ion 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
2856
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
1603
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
4675
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
1490
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" public="-//W3C//NOTATION XML 1.0: CDATA//EN" />
3
2554
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
1409
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 that are not part of the schema, doesn't catch missing tags where the schema has minoccurs="1", and...
1
2105
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" elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0.1">
2
7169
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
8162
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
8565
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8246
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
8415
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7039
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4045
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
4109
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1695
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1413
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.