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
[quoted text, click to view] "Adam Smith" <adam2001usa@hotmail.com> wrote in message
news:OA4kAv7TEHA.3976@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!