2012-01-18 2 views
7

이 단지 형 선언 foo.xsd에서 기존 XSD 스키마된다XSD 유형을 루트 스키마로 가져 오는 방법은 무엇입니까?

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" 
    targetNamespace="foo"> 
    <xs:import schemaLocation="foo.xsd" namespace="foo" /> 
    <xs:element name="RootElement" type="alpha"/> 
</xs:schema> 

이것은 내가 SAX에서지고있어 무엇 :이 요소를 선언 다른 스키마입니다

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" 
    targetNamespace="foo"> 
    <xs:complexType name="alpha"> 
    <!-- skipped --> 
    </xs:complexType> 
</xs:schema> 

자바 파서 :

"The namespace attribute 'foo' of an <import> element information 
item must not be the same as the targetNamespace of the schema it exists in." 

내가 뭘 잘못하고 있니?

답변

14

관련된 XSD의 targetNamespace (tns) 속성이 지정되고 동일하면 xsd : include 만 허용됩니다 (targetNamespace 속성은 빈 문자열을 값으로 가질 수 없음).

그러나 tns가있는 스키마 (s2)의 tns가없는 스키마 (s1)를 포함 할 수 있습니다. 그물 효과는 s1 구성 요소가 s2 스키마의 네임 스페이스를 가정합니다. 이 사용법은 카멜레온 성분이라고도합니다.

두 가지의 차이점을 설명하는 SO는 here입니다.

+0

고마워요, 이것이 제가 찾고 있던 것입니다! – yegor256

+0

"tns"는 "targetNamespace"와 동일합니까? – Line

관련 문제