elementFormDefault
是什么,什么时候应该使用它?
我找到了一些关于elementFormDefault
值的定义:
qualified - 元素和属性在模式的 targetNamespace中
unqualified - 元素和属性没有命名空间
根据这个定义,如果一个模式被设置为qualified ,那么为什么必须要用命名空间来前缀类型呢?什么情况下会使用unqualified?我尝试过谷歌搜索,但只得到了一些极难理解的W3C页面。
这是我现在正在处理的文件,请问为什么我需要将类型声明为target:TypeAssignments
,当我已经将targetNamespace
声明为与xmlns:target
相同的命名空间?
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:target="http://www.levijackson.net/web340/ns"
targetNamespace="http://www.levijackson.net/web340/ns"
elementFormDefault="qualified">
<element name="assignments">
<complexType>
<sequence>
<element name="assignments" type="target:TypeAssignments"
minOccurs="1" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
<complexType name="TypeAssignments">
<sequence>
<element name="assignment" type="target:assignmentInfo"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
<complexType name="assignmentInfo">
<sequence>
<element name="name" type="string"/>
<element name="page" type="target:TypePage"/>
<element name="file" type="target:TypeFile"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
<attribute name="id" type="string" use="required"/>
</complexType>
<simpleType name="TypePage">
<restriction base="integer">
<minInclusive value="50" />
<maxInclusive value="498" />
</restriction>
</simpleType>
<simpleType name="TypeFile">
<restriction base="string">
<enumeration value=".xml" />
<enumeration value=".dtd" />
<enumeration value=".xsd" />
</restriction>
</simpleType>
</schema>