[
Lists Home |
Date Index |
Thread Index
]
Title: XML Schema Validation Problem
Hi everybody,
Firstly, I'm new to the list so a quick intro, I program in VB6 SP5 MSXML4 at work OS is Windows 2K Professional. My experience is fairly short with XML (approx 6-8 months), currently I am building XML-Schemas for data exchange between two progams. I have used XSLT in the past but it is not required for this project.
I am having a problem with namespaces at the moment and wondered if anyone could help. Obviously if this is the wrong forum for this question please let me know ;-)
I have a Schema that has 2 namespaces. This is referenced by an XML document. I can successfully parse the XML against the schema, however I cannot then assign any data to an Object using the SelectSingleNode method of a FreeThreadedDOMDocument40. According to the object browser this should return an IXMLDOMNode, the result I get is the object is still nothing. (Sample XML1)
***************
Sample XML1
***************
<?xml version="1.0" encoding="UTF-8"?>
<Environment xmlns="xyz" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="xyz simple_env.xsd">
</Environment>
*********************************
Sample Schema
Used with all 3 XML samples
*********************************
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="xyz"
xmlns="xyz"
elementFormDefault="unqualified" attributeFormDefault="unqualified">
<xs:element name="Environment">
</xs:element>
</xs:schema>
If I remove the Namespaces and just use a basic structure (Sample XML2), the xml still parses and I get a return value from SelectSingleNode. The only problem being that the schema is not then enforced and I can invent any tags I like in the xml without a parse error (Sample XML3).
****************
Sample XML2
****************
<?xml version="1.0" encoding="UTF-8"?>
<Environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="xyz simple_env.xsd">
</Environment>
****************
Sample XML3
****************
<?xml version="1.0" encoding="UTF-8"?>
<Environment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="xyz simple_env.xsd">
<fred/>
</Environment>
Incidentally I have tried using the Microsoft example from the MSDN and this has the same problem.
Thanks in advance
Jason
Jason Brown
I2 Limited
The Visual Space
Capital Park
Fubourn
Cambridge
CB1 5XH
Tel: (01223) 728 670
Fax: (01223) 728 601
Mobile: 07952 246 375
|