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

XmlValidatingReader problem

Hi

I am encoutering a problem during the validation of an XML document
when using 'XmlValidingReader'.

My setup is as follows.

I have a schema 'Document.xsd' which is imported into a further schema
'DerivedDocument.xsd'. Our xml sample 'Instancedoc.xml' uses
'DerivedDocument.xsd' as its schema.

A piece of c# code, which utilises an XmlValidingReader succeeds to
validate the xml when NO attributes are used from 'Document.xsd', but
fails when these attributes are included.
However, we can succesfully import complexTypes from 'Document.xsd'
and have these valiate correctly.

Document.xsd:
<?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://MyCompany/Core/Documents"
xmlns:documentBase="http://MyCompanu/Core/Documents"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"><xs:complexType name="BaseDocument"><xs:attribute name="name" type="xs:string" use="optional"/><xs:attribute name="locked" type="xs:boolean" use="optional"
default="true"/></xs:complexType></xs:schema>
DerivedDocument.xsd
<?xml version="1.0" encoding="utf-8"?><xs:schema targetNamespace="http://MyCompany/Department/Product/Documents/DerivedDocument"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mstns="http://MyCompany/Department/Product/Documents/DerivedDocuemnt"
xmlns="http://MyCompany/Department/Product/Documents/DerivedDocument"
xmlns:documentBase="http://MyCompany/Core/Documents"
elementFormDefault="qualified" attributeFormDefault="qualified"
id="CostOfTennor"><xs:import namespace="http://MyCompany/Core/Documents"
schemaLocation="Document.xsd"/><xs:element name="Point" type="PointType"/><xs:complexType name="PointType"><xs:sequence><xs:element name="Interval" type="xs:string"/><xs:element name="Value" type="xs:double"/></xs:sequence></xs:complexType><xs:element name="DerivedDocument"><xs:complexType><xs:complex Content><xs:extension base="documentBase:BaseDocument"><xs:sequence><xs: element name="Author" type="xs:string"/><xs:element name="Points" type="PointsType"/></xs:sequence></xs:extension></xs:complexContent></xs:complexType></xs:element><xs:element name="Points" type="PointsType"/><xs:complexType name="PointsType"><xs:sequence minOccurs="0" maxOccurs="unbounded"><xs:element name="Point" type="PointType"/></xs:sequence></xs:complexType></xs:schema>
Instancedoc.xml
<?xml version="1.0" encoding="UTF-8"?><n:DerivedDocument xmlns:n="http://MyCompany/Department/Product/Documents/DerivedDocument"
xmlns:documentBase="http://MyCompany/Core/Documents"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:mstns="http://MyCompany/Department/Product/Documents/DerivedDocuemnt"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://MyCompany/Department/Product/Documents/DerivedDocument
DerivedDocument.xsd" documentBase:locked="false"><n:Author>Me</n:Author><n:Points><n:Point><n:Interval>6 Months</n:Interval><n:Value>1.0</n:Value></n:Point><n:Point><n:Interval>6 Months</n:Interval><n:Value>2.0</n:Value></n:Point></n:Points></n:DerivedDocument>
Is this a bug with XmlValidingReader or am I constructing my
schemas/xml incorrectly?

Any help would be really appreciated

Mark

Nov 12 '05 #1
1 1092
Set attributeFormDefault="qualified" in Document.xsd

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

"Mark Collins" <an*******@discussions.microsoft.com> wrote in message
news:11**********************************@microsof t.com...
Hi

I am encoutering a problem during the validation of an XML document
when using 'XmlValidingReader'.

My setup is as follows.

I have a schema 'Document.xsd' which is imported into a further schema
'DerivedDocument.xsd'. Our xml sample 'Instancedoc.xml' uses
'DerivedDocument.xsd' as its schema.

A piece of c# code, which utilises an XmlValidingReader succeeds to
validate the xml when NO attributes are used from 'Document.xsd', but
fails when these attributes are included.
However, we can succesfully import complexTypes from 'Document.xsd'
and have these valiate correctly.

Document.xsd:
<?xml version="1.0" encoding="UTF-8"?><xs:schema targetNamespace="http://MyCompany/Core/Documents" xmlns:documentBase="http://MyCompanu/Core/Documents"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"><xs:complexType
name="BaseDocument"><xs:attribute name="name" type="xs:string"
use="optional"/><xs:attribute name="locked" type="xs:boolean" use="optional" default="true"/></xs:complexType></xs:schema>
DerivedDocument.xsd
<?xml version="1.0" encoding="utf-8"?><xs:schema targetNamespace="http://MyCompany/Department/Product/Documents/DerivedDocume
nt" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mstns="http://MyCompany/Department/Product/Documents/DerivedDocuemnt" xmlns="http://MyCompany/Department/Product/Documents/DerivedDocument"
xmlns:documentBase="http://MyCompany/Core/Documents"
elementFormDefault="qualified" attributeFormDefault="qualified"
id="CostOfTennor"><xs:import namespace="http://MyCompany/Core/Documents"
schemaLocation="Document.xsd"/><xs:element name="Point" type="PointType"/><xs:complexType name="PointType"><xs:sequence><xs:element
name="Interval" type="xs:string"/><xs:element name="Value"
type="xs:double"/></xs:sequence></xs:complexType><xs:element
name="DerivedDocument"><xs:complexType><xs:complex Content><xs:extension
base="documentBase:BaseDocument"><xs:sequence><xs: element name="Author"
type="xs:string"/><xs:element name="Points"
type="PointsType"/></xs:sequence></xs:extension></xs:complexContent></xs:com
plexType></xs:element><xs:element name="Points"
type="PointsType"/><xs:complexType name="PointsType"><xs:sequence
minOccurs="0" maxOccurs="unbounded"><xs:element name="Point"
type="PointType"/></xs:sequence></xs:complexType></xs:schema>

Instancedoc.xml
<?xml version="1.0" encoding="UTF-8"?><n:DerivedDocument xmlns:n="http://MyCompany/Department/Product/Documents/DerivedDocument" xmlns:documentBase="http://MyCompany/Core/Documents"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
xmlns:mstns="http://MyCompany/Department/Product/Documents/DerivedDocuemnt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://MyCompany/Department/Product/Documents/DerivedDoc
ument DerivedDocument.xsd" documentBase:locked="false"><n:Author>Me</n:Author><n:Points><n:Point><n:Int
erval>6
Months</n:Interval><n:Value>1.0</n:Value></n:Point><n:Point><n:Interval>6
Months</n:Interval><n:Value>2.0</n:Value></n:Point></n:Points></n:DerivedDoc
ument>

Is this a bug with XmlValidingReader or am I constructing my
schemas/xml incorrectly?

Any help would be really appreciated

Mark

Nov 12 '05 #2

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

Similar topics

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...
4
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...
3
by: Nuevo Registrado | last post by:
All, I am having a tough time figuring out how to code a simple app to read an xml file and an xsd file and validate the xml file using the xsd without using a namespace for the schema. Help?...
1
by: George W. | last post by:
When attempting to validate an XML file, If the file is valid, it validates correctly, and it will catch most ValidationEvents without problem. However, I keep getting 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: Wolfgang Uhr | last post by:
Hello I have the following problem. I want to use the validating parser XmlValidatingReader and so I write ... FileStream stream = new FileStream(ofd.FileName, FileMode.Open);...
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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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:
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,...

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.