,이 세 가지 XSD를 고려합니다. 그것들은 모두이를 참조하는 하나의 전역 유형과 하나의 전역 요소 정의를 정의합니다.
먼저 xsd가 위에 게시 된 것과 같습니다. 이 스키마 네임 스페이스 접두사 'XSD'과의 targetNamespace에 대한 기본 네임 스페이스 사용 : 이제
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/"
xmlns="http://example.com/">
<xsd:element name="aGlobalElement" type="aGlobalType"/>
<xsd:simpleType name="aGlobalType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
같은 XSD를하지만 정의하고 대상 네임 스페이스에 대한 네임 스페이스 접두사를 사용하여 :
<xsd:schema
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/"
xmlns:tns="http://example.com/">
<xsd:element name="aGlobalElement" type="tns:aGlobalType"/>
<xsd:simpleType name="aGlobalType">
<xsd:restriction base="xsd:string"/>
</xsd:simpleType>
</xsd:schema>
... 그리고 마지막으로, 대신 XML 스키마 네임 스페이스에 대한 'XSD'의 기본 네임 스페이스를 사용하는 버전 :
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://example.com/"
xmlns:tns="http://example.com/">
<element name="aGlobalElement" type="tns:aGlobalType"/>
<simpleType name="aGlobalType">
<restriction base="string"/>
</simpleType>
</schema>
스키마 저자 대부분의 경우 때문에, 첫 번째 또는 마지막 선택 기본 네임 스페이스 기능을 사용할 수있는 경우 무언가에에 사용할 수 있습니다.
하지만, 대답은 할 수 없습니다 XMLNS 기본 네임 스페이스입니다 이 문서 (스키마 문서)에 대한 targetNamespace는이 스키마 문서의 유효성을 검사하는 네임 스페이스입니까? 그리고 이런 식으로 xmlns와 targetNamespace는 두 가지 다른 것들입니까? – Vering
@ 테스트 결과 찾기는 첫 번째 문장과 일치합니다. 예. targetNamespace는 스키마가 확인하는 문서를 확실히 참조합니다. targetNamespace의 존재는 또한 'xmlns'또는 'xmlns : xxx'가 있어야합니다. 실제로 많은 'xmlns : xxx', 'xmlns : yyy'및 'xmlns'를 함께 사용할 수 있으며 유효성을 검사합니다. – ifelsemonkey