2017-10-05 1 views
0

XSD를 처음 사용했기 때문에 XSD가 유효성을 검사하지 않는 이유를 알 수 없습니다. 다음과 같은 오류가 발생합니다 :XSD가 xml 유효성 검사를하지 않음

s4s-elt-invalid-content.1 : 'parametersInfo'의 내용이 유효하지 않습니다. 'complexType'요소가 잘못되었거나 잘못 배치되었거나 너무 자주 발생합니다.

cvc-complex-type.2.4.d : 'exception'요소로 시작하는 잘못된 콘텐츠가 발견되었습니다. 이 시점에서 하위 요소는 필요하지 않습니다.

XML :

<?xml version="1.0" encoding="UTF-8"?> 
<service id="IServiceREST"> 
      <inherit> 
       <parent>Remote</parent> 
      </inherit> 
      <package>com.module</package> 
      <include>java.rmi.Remote</include> 
      <include>java.net.*</include> 
      <include>java.io.*</include> 
      <abstract_method id="getContent"> 
       <visibility>public</visibility> 
       <parameters> 
        <argument type="URL">url</argument> 
        <argument type="int">timeout</argument> 
       </parameters> 
       <throw> 
        <exception>MalformedURLException</exception> 
        <exception>IOException</exception> 
       </throw> 
       <return>String</return> 
      </abstract_method> 
      <abstract_method id="deleteUser"> 
       <visibility>public</visibility> 
       <parameters> 
        <argument type="String">username</argument> 
       </parameters> 
       <return>void</return> 
      </abstract_method> 
</service> 

XSD :

<xs:schema 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
    <xs:complexType name="serviceInfo"> 
     <xs:sequence> 
      <xs:element name="inherit" type="inheritInfo" minOccurs="1" maxOccurs="unbounded"/> 
      <xs:element name="package" type="xs:string" /> 
      <xs:element name="include" type="xs:string" minOccurs="0" maxOccurs="unbounded" /> 
      <xs:element name="abstract_method" type="abstract_methodInfo" minOccurs="0" maxOccurs="unbounded" /> 
     </xs:sequence> 
     <xs:attribute type="xs:string" name="id" /> 
    </xs:complexType> 

    <xs:complexType name="inheritInfo"> 
     <xs:sequence> 
      <xs:element type="xs:string" name="parent" /> 
     </xs:sequence> 
    </xs:complexType> 

    <xs:complexType name="abstract_methodInfo"> 
     <xs:sequence> 
      <xs:element type="xs:string" name="visibility" minOccurs="0" maxOccurs="1"/> 
      <xs:element type="parametersInfo" name="parameters" />  
      <xs:element type="throwInfo" name="throw" minOccurs="0" maxOccurs="unbounded"/> 
      <xs:element type="xs:string" name="return" minOccurs="1" /> 
     </xs:sequence> 
     <xs:attribute type="xs:string" name="id" /> 
    </xs:complexType> 


    <xs:complexType name="throwInfo"> 
     <xs:sequence> 
      <xs:element type="xs:string" name ="exception" /> 
     </xs:sequence> 
    </xs:complexType> 

    <xs:complexType name="parametersInfo"> 
      <xs:complexType type="xs:string" name="argument"> 
      <xs:sequence> 
       <xs:element name="URL" type="xs:string" minOccurs="0" maxOccurs="unbounded"/> 
       <xs:element name="timeout" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/> 
      </xs:sequence> 
      </xs:complexType> 
    </xs:complexType> 
    <xs:element name="service" type="serviceInfo"/> 
</xs:schema>  

오전 내가 뭔가 빠진? 나는 형 parametersInfo

답변

0

귀하의 선언은

<xs:complexType name="parametersInfo"> 
    <xs:complexType type="xs:string" name="argument"> 
    <xs:sequence> 
     <xs:element name="URL" type="xs:string" 
        minOccurs="0" maxOccurs="unbounded"/> 
     <xs:element name="timeout" type="xs:integer" 
        minOccurs="0" maxOccurs="unbounded"/> 
    </xs:sequence> 
    </xs:complexType> 
</xs:complexType> 

는 XSD complexType 요소가 complexType의 자식으로 나타날 수 없습니다 읽고 ... 복잡한 유형을 사용하고 분해를 참조하여 쉽게 만들고 싶었다. 나는 네가 뭘 하려는지는 모르지만,이 일은 그렇게 할 수있는 방법이 아니다.

XSD의 튜토리얼 또는 튜토리얼을 통해 작업해야 할 수 있습니다.

관련 문제