2011-08-31 3 views
2

XML 스키마에서 ID 필드를 구별 할 수 있는지 궁금합니다. 다음 스키마가 있습니다.XML 스키마 (XSD)에서 여러 ID 참조

<element name="define_apple"> 
    <complexType> 
     <attribute name="colour" type="ID"/> 
    </complexType> 
</element> 

<element name="define_orange"> 
    <complexType> 
     <attribute name="colour" type="ID"/> 
    </complexType> 
</element> 

<element name="reference_apple"> 
    <complexType> 
     <attribute name="colour" type="IDREF"/> 
    </complexType> 
</element> 

<element name="reference_orange"> 
    <complexType> 
     <attribute name="colour" type="IDREF"/> 
    </complexType> 
</element> 

그러나 참조는 각각의 정의와 고유하게 연결되어 있지 않습니다.

<define_apple colour="green"/> 
<define_orange colour="orange"/> 

<reference_apple colour="orange"/> 
<reference_orange colour="green"/> 

제대로 네임 스페이스를 사용하여 예를 들어, ID 및 IDREF를 사용하여 필드를 연결하는 방법이 있나요 : 나는 아직도 다음과 같은 말도 있지만 유효한 XML을 쓸 수 있습니까? 나는 key와 keyref를 사용할 수 있다는 것을 알고 있지만 ID는 좀 더 호소력이있다.

답변

1

아니요, 가능하지 않다고 생각합니다. http://www.w3.org/TR/xmlschema-2/#IDhttp://www.w3.org/TR/xmlschema-2/#IDREF은 ID 및 IDREF 속성 유형이 XML 표준에서 왔으며 http://www.w3.org/TR/2000/WD-xml-2e-20000814#NT-TokenizedType은 IDREF의 유효성 제한이 문서의 일부 ID와 일치한다고 말합니다. 나는 ID와 IDREF가 DTD와의 하위 호환성을 위해 대부분 XML 스키마에 있다고 생각한다.

+0

수치심 ... 이것을 지적 해 주셔서 감사합니다. – DonDiesl