0
- 據我所知,在XML(和)XSD用於減輕 引用的元素和屬性的二義性的命名空間。
- XML模式的屬性的targetNamespace爲specifiying的 命名空間,在該文件(或一切 ,其具有的targetNamespace在元件內部)中定義的元素對應於。此 僅適用於在此上下文中「聲明」的元素(其名稱中包含 的名稱在屬性「name」中聲明)。因此,如果我在Schema中聲明目標名稱空間,那麼我對它進行驗證的每個實例都必須在架構中聲明的任何元素或屬性之前使用該名稱空間,或者將其聲明爲默認名稱空間以使我不必在每個實例之前鍵入該架構與它。
如果有任何的不妥,一定要指正。無法驗證XML針對與targetNamespace生成XSD,當XSD具有複合類型
是什麼力量推動我瘋了,這是爲什麼不這樣:
<?xml version="1.0" encoding="UTF-8"?>
<responsabilities xmlns="http://www.library.org">
<responsability>uno</responsability>
<responsability>dos</responsability>
<responsability>tres</responsability>
</responsabilities>
...驗證對這樣的:
<?xml version="1.0" encoding="UTF-8"?>
<schema targetNamespace="http://www.library.org" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:bpd="http://www.library.org" >
<element name="responsabilities" type="bpd:responsabilitiesType"/>
<complexType name="responsabilitiesType">
<sequence>
<element maxOccurs="unbounded" name="responsability" type="string" />
</sequence>
</complexType>
</schema>
它顯示了這個錯誤:
The element 'responsabilities' in namespace ' http://www.library.org ' has invalid child element 'responsability' in namespace ' http://www.library.org '. List of possible elements expected: 'responsability'. Line: 1 Column:90
我使用相同的名稱空間方案對SimpleType進行驗證,並且完全沒有問題。
謝謝。