2013-08-06 4 views
0

xsd : 요소 형식을 XMLSchema (XSD 파일의 구조를 정의)로 설정하려면 어떻게해야합니까? 심지어 가능할까요?xml 스키마 형식의 요소 선언

<schemas xmlns:xs=''> 
    <xs:schema...> 
    <xs:element name='...'/> 
    </xs:schema> 
    <xs:schema...> 
    </xs:schema> 
</schemas> 

이 XML의 스키마는 다음과 같이 보일 것이다 :

물론
<xs:schema xmlns:xs=''> 
    <xs:element name='schemas'> 
    <xs:complexType> 
     <xs:sequence> 
     <xs:element name='schema' type='xs:schema' 
      minoccurs='0' maxoccurs='unbounded'/> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 
</xs:schema> 

이있다

예를 들어, 나는 그것의 루트 요소 아래에 여러 XSD를을 나열하는 XML 파일이 필요 그러한 유형은 xs:schema입니다. 이 작품을 어떻게 만들 수 있습니까?

답변

3

예, 가능합니다.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> 

    <!-- 
    Any XML schema processor does know XML schema language, 
    but it is not supposed to know an XML schema for it. 
    You need to import it! 
    --> 
    <xs:import namespace="http://www.w3.org/2001/XMLSchema" 
      schemaLocation="http://www.w3.org/2001/XMLSchema.xsd"/> 

    <xs:element name="schemas"> 
    <xs:complexType> 
     <xs:sequence> 
     <!-- 
      You don't need an 'xs:schema' type. Rather you just need 
      to reference an already existing 'xs:schema' element 
     --> 
     <xs:element minoccurs="0" maxoccurs="unbounded" ref="xs:schema"/> 
     </xs:sequence> 
    </xs:complexType> 
    </xs:element> 

</xs:schema> 

당신은 XSLT에 대한 XML 스키마도 볼 수 있습니다 방법은 다음과 같습니다 http://www.w3.org/2007/schema-for-xslt20.xsd. 그들은 <xsl:import-schema> 요소의 정의에서 동일합니다.