2013-05-31 3 views
0

첫 번째 두 경우 중 하나라도 허용되지만 후자의 경우는 허용되지 않습니다. 이 xml에 대해 xsd를 만들 수 있습니까? 아니면 유효하지 않습니까?독점 또는 대소 문자에 대한 XML 스키마?

<book id="something" /> 

<!-- or --> 

    <book>something</book> 

<!--not --> 

< 
<book id="something"> 
    something else 
</book> 

편집 : 여기 내가 사용하려고 시도했습니다 스키마의 - XSD에서

<xs:simpleType name="book"> 
    <xs:restriction base="xs:string"> 
    </xs:restriction> 
</xs:simpleType> 


<xs:complexType name="book2"> 
    <xs:simpleContent> 
     <xs:extension base="or:book"> 
      <xs:attribute name="id" type="xs:string" /> 
     </xs:extension> 
    </xs:simpleContent> 
    </xs:complexType> 

<xs:complexType name="book3"> 
    <xs:simpleContent> 
     <xs:restriction base="or:book2"> 
      <xs:maxLength value="0" /> 
     </xs:restriction> 
    </xs:simpleContent> 
</xs:complexType> 

<xs:element name="root"> 
    <xs:complexType> 
     <xs:choice> 
      <xs:element name="book" maxOccurs="unbounded" type="or:book" /> 
      <xs:element name="book" maxOccurs="unbounded" type="or:book3" /> 
     </xs:choice> 
    </xs:complexType> 
</xs:element> 

답변

0

... 난 아직도 XML에 아주 새로운 해요, 그래서 나는 그것이 옳다에 가까이 약속 할 수 1.0 요소의 내용에 대한 규칙은 요소의 특성에 의존 할 수 없습니다. XSD 1.1에서는 조건부 유형 지정이라고 할 수 있습니다. 그래서 질문에 대한 대답은 당신이 말하는 XSD의 버전에 달려 있습니다.

+0

아, 글쎄, 1.0을 사용하고 있으며 Eclipse를 사용하고 있습니다. 1.1을 사용하거나 1.0에서 사용할 수있는 좋은 플러그인을 알고 있습니까? – Jefftopia

+0

Java 세계에는 Xerces 버전과 자체 Saxon 프로세서의 두 가지 XSD 1.1 프로세서가 있습니다. –