,当我想作一个简单的架构空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