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

XmlValidatingReader too sensitive?

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
schema that is coming from a third party. The schema 2 is a wrapper
around that document.

The problem comes into light when a document based upon schema 1 has an
element outside of any namespace. Even though I qualify the tag, as in
<Hierarchy xmlns="">, xmlvalidatingreader chokes on it. xmlspy is fine.

schema 1 (3rd party)
--------
<xsd:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified">
<xsd:complexType name="StaffingOrderType">
<xsd:element name="samplefield" type="xsd:string" />
</xsd:complexType>
<xsd:element name="StaffingOrder" type="StaffingOrderType" />
</xsd:schema>

schema 2 (our wrapper hosted on our side)
--------
<xs:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified" id="MultipleHRXML">
<xs:include schemaLocation="StaffingOrder-1_0.xsd" />
<xs:complexType name="MultipleHRXMLSidesType">
<xs:element name="StaffingOrder" type="StaffingOrderType" />
</xs:complexType>

<xs:element name="MultipleHRXML-SIDES" type="MultipleHRXMLSidesType" />
</xs:schema>

example doc based on schema 2
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<MultipleHRXML-SIDES xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://localhost/HRXML/SIDES/SIDES-1_0/MultipleHRXML-SIDES-1_0.xsd">

<StaffingOrder xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://ns.hr-xml.org/SIDES/SIDES-1_0/StaffingOrder-1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0">
<samplefield>test</samplefield>

<!-- *****NOTE BELOW CAUSES THE PROBLEM******-->

<Hierarchy xmlns="">somevalue</Hierarchy>
</StaffingOrder>
</MultipleHRXML-SIDES>

---Thanks in advance
Adam Smith

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 12 '05 #1
4 1556
Your XML schema is for elements from the
"http://ns.hr-xml.org/SIDES/SIDES-1_0" namespace. Your element is explicitly
set to having no namespace using xmlns="" and you have elementFormDefault
set to qualifued meaning that the element should be in the target namespace
of the schema.

Read the article at
http://msdn.microsoft.com/library/en...ml08192002.asp for
more information on this.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Adam Smith" <ad*********@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
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
schema that is coming from a third party. The schema 2 is a wrapper
around that document.

The problem comes into light when a document based upon schema 1 has an
element outside of any namespace. Even though I qualify the tag, as in
<Hierarchy xmlns="">, xmlvalidatingreader chokes on it. xmlspy is fine.

schema 1 (3rd party)
--------
<xsd:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified">
<xsd:complexType name="StaffingOrderType">
<xsd:element name="samplefield" type="xsd:string" />
</xsd:complexType>
<xsd:element name="StaffingOrder" type="StaffingOrderType" />
</xsd:schema>

schema 2 (our wrapper hosted on our side)
--------
<xs:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified" id="MultipleHRXML">
<xs:include schemaLocation="StaffingOrder-1_0.xsd" />
<xs:complexType name="MultipleHRXMLSidesType">
<xs:element name="StaffingOrder" type="StaffingOrderType" />
</xs:complexType>

<xs:element name="MultipleHRXML-SIDES" type="MultipleHRXMLSidesType" />
</xs:schema>

example doc based on schema 2
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<MultipleHRXML-SIDES xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://localhost/HRXML/SIDES/SIDES-1_0/MultipleHRXML-SIDES-1_0.xsd">

<StaffingOrder xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://ns.hr-xml.org/SIDES/SIDES-1_0/StaffingOrder-1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0">
<samplefield>test</samplefield>

<!-- *****NOTE BELOW CAUSES THE PROBLEM******-->

<Hierarchy xmlns="">somevalue</Hierarchy>
</StaffingOrder>
</MultipleHRXML-SIDES>

---Thanks in advance
Adam Smith

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #2
Your XML schema is for elements from the
"http://ns.hr-xml.org/SIDES/SIDES-1_0" namespace. Your element is explicitly
set to having no namespace using xmlns="" and you have elementFormDefault
set to qualifued meaning that the element should be in the target namespace
of the schema.

Read the article at
http://msdn.microsoft.com/library/en...ml08192002.asp for
more information on this.

--
This posting is provided "AS IS" with no warranties, and confers no rights.

"Adam Smith" <ad*********@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
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
schema that is coming from a third party. The schema 2 is a wrapper
around that document.

The problem comes into light when a document based upon schema 1 has an
element outside of any namespace. Even though I qualify the tag, as in
<Hierarchy xmlns="">, xmlvalidatingreader chokes on it. xmlspy is fine.

schema 1 (3rd party)
--------
<xsd:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified">
<xsd:complexType name="StaffingOrderType">
<xsd:element name="samplefield" type="xsd:string" />
</xsd:complexType>
<xsd:element name="StaffingOrder" type="StaffingOrderType" />
</xsd:schema>

schema 2 (our wrapper hosted on our side)
--------
<xs:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified" id="MultipleHRXML">
<xs:include schemaLocation="StaffingOrder-1_0.xsd" />
<xs:complexType name="MultipleHRXMLSidesType">
<xs:element name="StaffingOrder" type="StaffingOrderType" />
</xs:complexType>

<xs:element name="MultipleHRXML-SIDES" type="MultipleHRXMLSidesType" />
</xs:schema>

example doc based on schema 2
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<MultipleHRXML-SIDES xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://localhost/HRXML/SIDES/SIDES-1_0/MultipleHRXML-SIDES-1_0.xsd">

<StaffingOrder xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://ns.hr-xml.org/SIDES/SIDES-1_0/StaffingOrder-1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0">
<samplefield>test</samplefield>

<!-- *****NOTE BELOW CAUSES THE PROBLEM******-->

<Hierarchy xmlns="">somevalue</Hierarchy>
</StaffingOrder>
</MultipleHRXML-SIDES>

---Thanks in advance
Adam Smith

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #3
The "StaffingOrderType" declares only one element SampleField. Once a schema
is found for the xml, XmlValidatingReader will validate according to that
schema and will not skip elements that do not belong to the targetNamespace.
XmlSPY has a bug here as the content model of StaffingOrderType does not
allow anything else other than the samplefield element.

Hence, undeclaring the default namespace in <Hierarchy
xmlns="">somevalue</Hierarchy> will not make the validating reader skip
validation for this element.

If you need elements in the empty namespace to be allowed as children of the
"StaffingOrder" element, then you need to define StaffingOrderType as open
content model using xs:any:
<xsd:complexType name="StaffingOrderType">
<xsd:sequence>
<xsd:element name="samplefield" type="xsd:string" />
<xsd:any namespace="##local" processContents="lax"/> --> ##local
allows only elements with no namespace
</xsd:sequence>
</xsd:complexType>

Thanks,
Priya

"Adam Smith" <ad*********@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
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
schema that is coming from a third party. The schema 2 is a wrapper
around that document.

The problem comes into light when a document based upon schema 1 has an
element outside of any namespace. Even though I qualify the tag, as in
<Hierarchy xmlns="">, xmlvalidatingreader chokes on it. xmlspy is fine.

schema 1 (3rd party)
--------
<xsd:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified">
<xsd:complexType name="StaffingOrderType">
<xsd:element name="samplefield" type="xsd:string" />
</xsd:complexType>
<xsd:element name="StaffingOrder" type="StaffingOrderType" />
</xsd:schema>

schema 2 (our wrapper hosted on our side)
--------
<xs:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified" id="MultipleHRXML">
<xs:include schemaLocation="StaffingOrder-1_0.xsd" />
<xs:complexType name="MultipleHRXMLSidesType">
<xs:element name="StaffingOrder" type="StaffingOrderType" />
</xs:complexType>

<xs:element name="MultipleHRXML-SIDES" type="MultipleHRXMLSidesType" />
</xs:schema>

example doc based on schema 2
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<MultipleHRXML-SIDES xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://localhost/HRXML/SIDES/SIDES-1_0/MultipleHRXML-SIDES-1_0.xsd">

<StaffingOrder xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://ns.hr-xml.org/SIDES/SIDES-1_0/StaffingOrder-1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0">
<samplefield>test</samplefield>

<!-- *****NOTE BELOW CAUSES THE PROBLEM******-->

<Hierarchy xmlns="">somevalue</Hierarchy>
</StaffingOrder>
</MultipleHRXML-SIDES>

---Thanks in advance
Adam Smith

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #4
The "StaffingOrderType" declares only one element SampleField. Once a schema
is found for the xml, XmlValidatingReader will validate according to that
schema and will not skip elements that do not belong to the targetNamespace.
XmlSPY has a bug here as the content model of StaffingOrderType does not
allow anything else other than the samplefield element.

Hence, undeclaring the default namespace in <Hierarchy
xmlns="">somevalue</Hierarchy> will not make the validating reader skip
validation for this element.

If you need elements in the empty namespace to be allowed as children of the
"StaffingOrder" element, then you need to define StaffingOrderType as open
content model using xs:any:
<xsd:complexType name="StaffingOrderType">
<xsd:sequence>
<xsd:element name="samplefield" type="xsd:string" />
<xsd:any namespace="##local" processContents="lax"/> --> ##local
allows only elements with no namespace
</xsd:sequence>
</xsd:complexType>

Thanks,
Priya

"Adam Smith" <ad*********@hotmail.com> wrote in message
news:OA**************@TK2MSFTNGP09.phx.gbl...
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
schema that is coming from a third party. The schema 2 is a wrapper
around that document.

The problem comes into light when a document based upon schema 1 has an
element outside of any namespace. Even though I qualify the tag, as in
<Hierarchy xmlns="">, xmlvalidatingreader chokes on it. xmlspy is fine.

schema 1 (3rd party)
--------
<xsd:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified">
<xsd:complexType name="StaffingOrderType">
<xsd:element name="samplefield" type="xsd:string" />
</xsd:complexType>
<xsd:element name="StaffingOrder" type="StaffingOrderType" />
</xsd:schema>

schema 2 (our wrapper hosted on our side)
--------
<xs:schema targetNamespace="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
elementFormDefault="qualified" id="MultipleHRXML">
<xs:include schemaLocation="StaffingOrder-1_0.xsd" />
<xs:complexType name="MultipleHRXMLSidesType">
<xs:element name="StaffingOrder" type="StaffingOrderType" />
</xs:complexType>

<xs:element name="MultipleHRXML-SIDES" type="MultipleHRXMLSidesType" />
</xs:schema>

example doc based on schema 2
-----------------------------
<?xml version="1.0" encoding="UTF-8"?>
<MultipleHRXML-SIDES xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://localhost/HRXML/SIDES/SIDES-1_0/MultipleHRXML-SIDES-1_0.xsd">

<StaffingOrder xsi:schemaLocation="http://ns.hr-xml.org/SIDES/SIDES-1_0
http://ns.hr-xml.org/SIDES/SIDES-1_0/StaffingOrder-1_0.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://ns.hr-xml.org/SIDES/SIDES-1_0">
<samplefield>test</samplefield>

<!-- *****NOTE BELOW CAUSES THE PROBLEM******-->

<Hierarchy xmlns="">somevalue</Hierarchy>
</StaffingOrder>
</MultipleHRXML-SIDES>

---Thanks in advance
Adam Smith

*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 12 '05 #5

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

Similar topics

1
by: Alejandro Calbazana | last post by:
Hello, Should the XmlValidatingReader validating xml against an xsd serially (e.g. - does the XML have to be in the correct position in order for a document to be valid)? For example, I am...
18
by: Vlad | last post by:
I have the following code: I have a local copy of the DTD that I need to validate incoming XML documents against. The XML document has the <!DOCTYPE myname SYSTEM "myfile.dtd"> define. When the...
0
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...
4
by: Jesse Elve | last post by:
I am using an XmlValidatingReader which uses an XSD for xml validation. The code has been performing reliably for months. Yesterday it failed for the first time with the following exception: ...
9
by: jason | last post by:
how do you use the XmlValidatingReader to validate an XML document that is passed into the XmlValidatingReader constructor? it looks like the normal process is to use an underlying reader, as...
5
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...
1
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"...
1
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST> xml file 2
12
by: Plop69 | last post by:
need some help on following: xml file 1 <TEST xmlns="http://test" > <OK>mlkddflmkj</OK> </TEST>
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.