Validate XML with Separated XSD
Hi,
I have received this .xsd file that has the following in it:
<?
xmlversion="1.0"encoding="UTF-8"?><
xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"xmlns:t="urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02"targetNamespace="urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02"><
xs:annotation><
xs:documentation><
RegistryEntryName="ProcessKitOrder"><
Description>ProcessKitOrder</< FONT>Description></< FONT>RegistryEntry></< FONT>xs:documentation>
</< FONT>xs:annotation>
<
xs:includeschemaLocation="../types/SchemaVersion_v0-01.xsd" /><
xs:includeschemaLocation="../types/MessageHeader_v0-02.xsd" /><
xs:includeschemaLocation="../types/OrderId_v0-01.xsd" /><
xs:includeschemaLocation="../types/OrderItems_v0-02.xsd" /><
xs:elementname="ProcessKitOrder"><
xs:complexType><
xs:sequence><
xs:elementname="SchemaVersion"type="t:SchemaVersionType"default="0.02" /><
xs:elementname="MessageHeader"type="t:MessageHeaderType" /><
xs:elementname="KitOrder"><
xs:complexType><
xs:sequence><
xs:elementname="OrderId"type="t:OrderIdType" /><
xs:elementname="OrderItems"type="t:OrderItemsType" /></< FONT>xs:sequence>
</< FONT>xs:complexType>
</< FONT>xs:element>
</< FONT>xs:sequence>
</< FONT>xs:complexType>
</< FONT>xs:element>
</< FONT>xs:schema>
As you can see it has a lot of sub-xsd's but I think they aren't declared properly. For example the SchemaVersionType contains the following:
<?<?
xmlversion="1.0"encoding="UTF-8"?><
xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"><
xs:annotation><
xs:documentation><
RegistryEntryName="SchemaVersion"><
Description>SchemaVersion</< FONT>Description></< FONT>RegistryEntry></< FONT>xs:documentation>
</< FONT>xs:annotation>
<
xs:simpleTypename="SchemaVersionType"><
xs:restrictionbase="xs:string"><
xs:minLengthvalue="1"/><
xs:maxLengthvalue="16"/></< FONT>xs:restriction>
</< FONT>xs:simpleType>
</< FONT>xs:schema>
Isn't it supposed to have it's own namespace ? Anyway, this might be all good but when I try to validate an XML file I get the following error ->
The element 'ProcessKitOrder' in namespace 'urn:be-tn:MVNO:Logistics
rocessKitOrder:0-02' has invalid child element 'SchemaVersion' in namespace 'urn:be-tn:MVNO:Logistics
rocessKitOrder:0-02'. List of possible elements expected: 'SchemaVersion'.
Does that make as much sense to you as it does to me?
I have tried to validate it in every single way. Currently I'm using the following:
Dim
xdAsNew XmlDocumentxd.LoadXml(xml)
xd.Schemas = GetSchema(xsd)
xd.Validate(
AddressOf ValidationHandler)xml = the xml in stringform and GetSchema(xsd) returns a shemaset containing the following schemas:
ss.Add(
"urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02", base_dir &"xsd\docs\ProcessKitOrder_v0-02.xsd")ss.Add(
"urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02:SchemaVersion", base_dir &"xsd\types\SchemaVersion_v0-01.xsd")'..... etc I'm not showing the rest but it's similar.
What am I doing wrong? Or is there something wrong with the .xsd/xml ? The xml is the following by the way .. I ripped out the bits that aren't referenced above.
<ProcessKitOrderxmlns="urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:be-tn:MVNO:Logistics:ProcessKitOrder:0-02 ../ProcessKitOrder_v0-02.xsd">
<SchemaVersion>0.02</SchemaVersion>
</ProcessKitOrder>

