,當我想作一個簡單的架構空elment錯誤驗證XML模式
<product orderid="4"/>
我創建了XSD像這樣:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://xml.netbeans.org/schema/first"
xmlns:tns="http://xml.netbeans.org/schema/first"
elementFormDefault="qualified">
<xsd:element name="product" type="prodtype"/>
<xsd:complexType name="prodtype">
<xsd:attribute name="prodid" type="xsd:integer"/>
</xsd:complexType>
</xsd:schema>
驗證對XML時,我得到了以下錯誤在XSD:
Error resolving component 'prodtype'. It was detected that 'prodtype' has no namespace, but components with no target namespace are not referenceable from schema document 'file:/D:/Teacher%20assistant%202011/First%20term/web%20services/test%20programs/BpelModule1/src/product.xsd'. If 'prodtype' is intended to have a namespace, perhaps a prefix needs to be provided. If it is intended that 'prodtype' has no namespace, then an 'import' without a "namespace" attribute should be added to 'file:/D:/Teacher%20assistant%202011/First%20term/web%20services/test%20programs/BpelModule1/src/product.xsd'.
btw,'xsd:schema'沒有在你的上面的代碼中關閉,可能是相關的嗎? – Piskvor
不,這只是在格式化方面的錯誤,這段代碼適用於我,但從xmlns:tns =「http://xml.netbeans.org/schema/first」中刪除「tns」之後,我直到現在才明白原因! – palAlaa