0
我必須使用XSD:關鍵不是XSD:ID,以便 我用這個代碼:爲什麼xsd:key xsd:keyref不能在xml文件上工作?
<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://www.checkbook.com/checkbook" xmlns="http://www.checkbook.com/checkbook" xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xs:element name="Serhat">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element name="Serhat2" type="type">
</xs:element>
</xs:choice>
</xs:complexType>
<xs:key name="PackageNameKey">
<xs:selector xpath=".//Serhat2"/>
<xs:field xpath="@id"/>
</xs:key>
</xs:element>
<xs:complexType name="type">
<xs:attribute name="id" type="xs:string" use="required"/>
</xs:complexType>
</xs:schema>
但關鍵不工作,我可以採取類似的id屬性;
<?xml version="1.0" encoding="utf-8"?>
<Serhat xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.checkbook.com/checkbook" xsi:schemaLocation="http://www.checkbook.com/checkbook denemeXSD.xsd">
<Serhat2 id="ser"/>
<Serhat2 id="ser"/>
</Serhat>
爲什麼不理解。任何想法?
是啊,它的工作thanx.But當我給默認的命名空間它不會工作 – gezgin 2012-02-21 17:58:03
XPath不具有默認命名空間不明白。您必須始終在XPath中明確表示。 – 2012-02-21 20:23:22
thanx。還有一個問題:我可以做這個代碼嗎? –
gezgin
2012-02-21 22:02:55