Xml 使用sql注释在xsd中支持递归关系
我有以下xsd,我无法理解为什么它在Xml 使用sql注释在xsd中支持递归关系,xml,xsd,bulk-load,Xml,Xsd,Bulk Load,我有以下xsd,我无法理解为什么它在“元素”上出现错误“此架构中无法引用命名空间”,以及如何修复它: <xsd:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2001/XMLSchema" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns
“元素”
上出现错误“此架构中无法引用命名空间”
,以及如何修复它:
<xsd:schema attributeFormDefault="unqualified"
elementFormDefault="qualified"
targetNamespace="http://www.w3.org/2001/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sql="urn:schemas-microsoft-com:mapping-schema">
<xsd:annotation>
<xsd:appinfo>
<sql:relationship name="PlayerPlayer"
parent="xmlTest"
parent-key="PlayerID"
child="xmlTest"
child-key="ParentID" />
</xsd:appinfo>
</xsd:annotation>
<xsd:element name="team">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="player" type="playerType"
maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:complexType name="playerType">
<xsd:sequence>
<xsd:element name="playerID" type="xsd:ID"/>
<xsd:element name="playerName" type="xsd:string"/>
<xsd:element name="playerCap" type="playerType"
minOccurs="0" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
感谢您的帮助 删除
@targetNamespace=”http://www.w3.org/2001/XMLSchema“
从根目录xsd:schema
元素,错误将消失。”
@targetNamespace
表示由XSD管理的XML文档实例的XML命名空间。您几乎肯定不希望XML文档位于XSD命名空间中
事实上,示例XML不使用名称空间,因此根本不需要@targetNamespace
。如果确实要使用名称空间,则对playerType
的引用必须以声明的名称空间前缀为前缀,以匹配@targetNamespace
的值
最后请注意,xmlns:sql=“urn:schemas microsoft com:mapping schema”
的声明与错误无关
<?xml version="1.0" encoding="UTF-8"?>
<team xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'
xsi:noNamespaceSchemaLocation='TestRecursive.xsd'>
<player>
<playerID>c1</playerID>
<playerName>Tommy Jones</playerName>
<playerCap>
<playerID>c2</playerID>
<playerName>Eddie Thomas</playerName>
<playerCap>
<playerID>c4</playerID>
<playerName>Patrick O’Shea</playerName>
</playerCap>
</playerCap>
</player>
</team>