2009-08-27 6 views
0

나는 차라리 수정할 것 하나 개 XSD 파일 (Exceptions.xsd)가 :XSD 구현의 버그입니까? 왜이 기능이 작동하지 않습니까?

<xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://me.com/Exceptions.xsd" 
     targetNamespace="http://me.com/Exceptions.xsd" 
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified" 
> 
    <xs:element name="Exception" type="ExceptionType" /> 

    <xs:complexType name="ExceptionType"> 
     <xs:sequence> 
      <xs:element name="Code" type="xs:string" minOccurs="0"/> 
      <xs:element name="Message" type="xs:string"/> 
      <xs:element name="TimeStamp" type="xs:dateTime"/> 
     </xs:sequence> 
    </xs:complexType> 
</xs:schema> 

내가 구현하는 다른 이름으로 새 요소를 생성 할 예외 유형이 (ExceptionsExtensions.xsd - 대안 1). 유형 'http://me.com/Exceptions.xsd:ExceptionType'선언되지 않은 :

<xs:schema 
     xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://me.com/Exceptions.xsd" 
     targetNamespace="http://me.com/Exceptions.xsd" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation= 
       " 
       http://me.com/Exceptions.xsd Exceptions.xsd 
       " 
     elementFormDefault="qualified" 
     attributeFormDefault="unqualified"> 

    <xs:element name="SpecificException" type="ExceptionType" /> 
</xs:schema> 

나는 오류 메시지가 표시됩니다. 나는이 (ExceptionExtensions.xsd - 대안 2) 할 것입니다 경우

그러나 :

<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://me.com/Exceptions.xsd" 
    targetNamespace="http://me.com/Exceptions.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation= 
      " 
      http://me.com/Exceptions.xsd Exceptions.xsd 
      " 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified"> 

    <xs:element name="SpecificException"> 
     <xs:complexType> 
      <xs:sequence> 
       <xs:element name="innerException"> 
        <xs:complexType> 
         <xs:sequence> 
          <xs:any namespace="http://me.com/Exceptions.xsd" />       
         </xs:sequence> 
        </xs:complexType> 
       </xs:element> 
      </xs:sequence> 
     </xs:complexType> 
    </xs:element> 

나는 그래서 대안 1가에 선언 된 예외 유형을 찾을 수 없습니다

<?xml version="1.0" encoding="utf-8"?> 
<SpecificException xmlns="http://me.com/Exceptions.xsd"> 
    <innerException> 
     <Exception> 
      <Code>12</Code> 
      <Message>Message</Message> 
      <TimeStamp>2009-08-27T11:30:00</TimeStamp> 
     </Exception> 
    </innerException> 
</SpecificException> 

유효성을 검사 할 수 있습니다 Exceptions.xsd가 있지만, 대안 2에서는 Exceptions.xsd에 선언 된 Exception 요소를 찾을 수 있습니다.

왜 대안 1이 효과가 없습니까?

종류와 관련, 기욤 Hanique 당신의 "대안 1"에서

답변

3

, 당신은 "예외 유형"을 참조하고 -하지만 어디 그 파일에 선언 아니에요.

두 파일이 동일한 네임 스페이스를 공유한다고해서 파일 A가 파일 B의 내용에 의존한다는 것을 의미하지는 않습니다. 두 파일을 연결해야합니다.

두 번째 파일에 <xsd:include>을 추가 트릭을 할해야

<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    xmlns="http://me.com/Exceptions.xsd" 
    targetNamespace="http://me.com/Exceptions.xsd" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://me.com/Exceptions.xsd Exceptions.xsd" 
    elementFormDefault="qualified" 
    attributeFormDefault="unqualified"> 

    <xs:include schemaLocation="exceptiontype.xsd"/> 

    <xs:element name="SpecificException" type="ExceptionType" /> 
</xs:schema> 

을!

마크

+0

고마워요! –

관련 문제