R
randar
I'm having problems getting an XML document to validate against a
fairly complex scenario.
Goals:
-To have two schemas with two different namespaces, so that I can
validate each one seperately against an XML doc. Hence why I'm using
xs:import instead of xs:include.
-To create some sample XML that will validate in Visual Studio and I
can use the tools there to enter in the XML data.
Here is the "base" schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="BaseSchema" targetNamespace="http://tempuri.org/Program"
elementFormDefault="qualified" xmlns="http://tempuri.org/Program"
xmlns:mstns="http://tempuri.org/Program"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="BaseElement" type="BaseComplexType">
</xs:element>
<xs:complexType name="BaseComplexType">
<xs:sequence>
<xs:element name="Primary" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Here is the sub schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SubSchema"
targetNamespace="http://tempuri.org/ProgramSub"
elementFormDefault="qualified" xmlns="http://tempuri.org/ProgramSub"
xmlns:mstns="http://tempuri.org/ProgramSub"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bs="http://tempuri.org/Program"
xmlns:ss="http://tempuri.org/ProgramSub">
<xs:import schemaLocation="BaseSchema.xsd"
namespace="http://tempuri.org/Program"></xs:import>
<xs:element name="SubElement" type="SubComplexType">
</xs:element>
<xs:complexType name="SubComplexType">
<xs:complexContent>
<xs:extension base="bs:BaseComplexType">
<xs:sequence>
<xs:element name="ExtraString" type="xs:string" />
<xs:element name="Foo" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Both of these seem to validate fine. When I create a new XML document
using VS, the data entry tools work fine and it generates:
<?xml version="1.0" encoding="utf-8"?>
<SubElement xmlns="http://tempuri.org/ProgramSub">
<Primary xmlns="http://tempuri.org/Program">1</Primary>
<ExtraString>sad</ExtraString>
<Foo>asdfasd</Foo>
</SubElement>
But it gives me the validation error of:
C:\Projects\Miscellaneous\Prototypes\ProgramManagement\Test.xml(3): The
active schema does not support the element 'Primary'.
So I tried to put namespaces in:
<?xml version="1.0" encoding="utf-8"?>
<ss:SubElement xmlns:ss="http://tempuri.org/ProgramSub"
xmlns:bs="http://tempuri.org/Program">
<bs
rimary>1</bs
rimary>
<ss:ExtraString>sd</ss:ExtraString>
<ss:Foo>sad</ss:Foo>
</ss:SubElement>
But still no luck.
C:\Projects\Miscellaneous\Prototypes\ProgramManagement\SubData.xml(3):
The active schema does not support the element 'bs
rimary'.
Anybody have an idea?
fairly complex scenario.
Goals:
-To have two schemas with two different namespaces, so that I can
validate each one seperately against an XML doc. Hence why I'm using
xs:import instead of xs:include.
-To create some sample XML that will validate in Visual Studio and I
can use the tools there to enter in the XML data.
Here is the "base" schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="BaseSchema" targetNamespace="http://tempuri.org/Program"
elementFormDefault="qualified" xmlns="http://tempuri.org/Program"
xmlns:mstns="http://tempuri.org/Program"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="BaseElement" type="BaseComplexType">
</xs:element>
<xs:complexType name="BaseComplexType">
<xs:sequence>
<xs:element name="Primary" type="xs:int" />
</xs:sequence>
</xs:complexType>
</xs:schema>
Here is the sub schema:
<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="SubSchema"
targetNamespace="http://tempuri.org/ProgramSub"
elementFormDefault="qualified" xmlns="http://tempuri.org/ProgramSub"
xmlns:mstns="http://tempuri.org/ProgramSub"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:bs="http://tempuri.org/Program"
xmlns:ss="http://tempuri.org/ProgramSub">
<xs:import schemaLocation="BaseSchema.xsd"
namespace="http://tempuri.org/Program"></xs:import>
<xs:element name="SubElement" type="SubComplexType">
</xs:element>
<xs:complexType name="SubComplexType">
<xs:complexContent>
<xs:extension base="bs:BaseComplexType">
<xs:sequence>
<xs:element name="ExtraString" type="xs:string" />
<xs:element name="Foo" type="xs:string" />
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
Both of these seem to validate fine. When I create a new XML document
using VS, the data entry tools work fine and it generates:
<?xml version="1.0" encoding="utf-8"?>
<SubElement xmlns="http://tempuri.org/ProgramSub">
<Primary xmlns="http://tempuri.org/Program">1</Primary>
<ExtraString>sad</ExtraString>
<Foo>asdfasd</Foo>
</SubElement>
But it gives me the validation error of:
C:\Projects\Miscellaneous\Prototypes\ProgramManagement\Test.xml(3): The
active schema does not support the element 'Primary'.
So I tried to put namespaces in:
<?xml version="1.0" encoding="utf-8"?>
<ss:SubElement xmlns:ss="http://tempuri.org/ProgramSub"
xmlns:bs="http://tempuri.org/Program">
<bs
<ss:ExtraString>sd</ss:ExtraString>
<ss:Foo>sad</ss:Foo>
</ss:SubElement>
But still no luck.
C:\Projects\Miscellaneous\Prototypes\ProgramManagement\SubData.xml(3):
The active schema does not support the element 'bs
Anybody have an idea?