Reputation: 97
I have a several XSD and try to verify my XML against them as:
First one (with nm_service values in (vl_1, vl_2)) common.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tii.ru/crmcom/uiconf/common"/>
<xsd:simpleType name="nm_service">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="vl_1" />
<xsd:enumeration value="vl_2" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
Second one (with some recursion) recur.xsd
<?xml version="1.0" encoding="utf-8" ?>
<!--XML Schema generated by QTAssistant/XML Schema Refactoring (XSR) Module
(http://www.paschidev.com) -->
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:p="http://tii.ru/crmcom/uiconf/common">
<xsd:import namespace="http://tii.ru/crmcom/uiconf/common"
schemaLocation="common.xsd" />
<xsd:element name="object">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0" />
<xsd:element ref="center" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="recursive">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0" />
<xsd:element ref="center" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="nm_service" type="p:nm_service"></xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="center" />
</xsd:schema>
Element with the name of recursive can have attribute nm_service with values defined in common.xsd
But when I try to validate
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<!-- Sample XML generated by QTAssistant (http://www.paschidev.com) -->
<object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://tempuri.org/XMLSchema.xsd">
<recursive>
<recursive nm_service="val_1" >
<recursive>
<center>
<recursive>
</recursive>
</center>
</recursive>
</recursive>
</recursive>
</object>
I got error The qname values does not resolve to a(n) simple type definition at
<xsd:attribute name="nm_service" type="p:nm_service"></xsd:attribute>
Any help would be appreciated. Thanks
Upvotes: 0
Views: 88
Reputation: 111491
Note: It seems that you may have posted XSDs inconsistent with the error message you reported.
Two main errors to fix:
xsd:schema
is self-closed where it shouldn't be.val_1
should be vl_1
.Altogether, the following XSDs will validate your XML successfully:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://tii.ru/crmcom/uiconf/common">
<xsd:simpleType name="nm_service">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="vl_1" />
<xsd:enumeration value="vl_2" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
<?xml version="1.0" encoding="utf-8" ?>
<xsd:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
elementFormDefault="qualified"
xmlns="http://tempuri.org/XMLSchema.xsd"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:p="http://tii.ru/crmcom/uiconf/common">
<xsd:import namespace="http://tii.ru/crmcom/uiconf/common"
schemaLocation="common.xsd" />
<xsd:element name="object">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0" />
<xsd:element ref="center" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="recursive">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="recursive" minOccurs="0" />
<xsd:element ref="center" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="nm_service" type="p:nm_service"></xsd:attribute>
</xsd:complexType>
</xsd:element>
<xsd:element name="center" />
</xsd:schema>
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<object xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://tempuri.org/XMLSchema.xsd"
xsi:schemaLocation="http://tempuri.org/XMLSchema.xsd recur.xsd">
<recursive>
<recursive nm_service="vl_1" >
<recursive>
<center>
<recursive>
</recursive>
</center>
</recursive>
</recursive>
</recursive>
</object>
Upvotes: 1
Reputation: 163262
You are missing namespace prefixes, for example
<xsd:element ref="recursive" minOccurs="0" />
should be
<xsd:element ref="p:recursive" minOccurs="0" />
Upvotes: 0