2015-08-19 72 views
-1

我的下一個XML:XSD非感測錯誤。屬性「過濾器」是不允許的

<!-- language: xml --> 
<Message name="Msg1" type="SIMPLE"> 
    <Doc> message to send </Doc> 
    <Parameters> 
     <Parameter name="param1" type="byte" filter="2" mask="On"> 
      <Fields> 
       <Field encode="hex"> 
        <Values> 
         <Value name="INDICATOR" id="0"/> 
        </Values> 
       </Field> 
      </Fields> 
     </Parameter> 
     <Parameter name="param2" type="byte" filter="3" mask="On"/> 
     <Parameter name="param3" type="byte"/> 
    </Parameters> 
</Message> 

和我的XSD文件是這個:

<xs:element name="Message" minOccurs="0" maxOccurs="unbounded"> 
     <xs:complexType> 
      <xs:choice maxOccurs="unbounded"> 
       <xs:element ref="Doc" minOccurs="0"/> 
       <xs:element name="Parameters" minOccurs="0"> 
        <xs:complexType> 
         <xs:choice maxOccurs="unbounded"> 
          <xs:element name="Parameter" minOccurs="0" maxOccurs="unbounded"> 
           <xs:complexType> 
            <xs:choice maxOccurs="unbounded"> 
             <xs:element ref="Doc" minOccurs="0"/> 
             <xs:element name="Fields" minOccurs="0"> 
              <xs:complexType> 
               <xs:choice maxOccurs="unbounded"> 
                <xs:element name="Field" minOccurs="0" maxOccurs="unbounded"> 
                 <xs:complexType> 
                  <xs:choice maxOccurs="unbounded"> 
                   <xs:element ref="Doc" minOccurs="0"/> 
                    <xs:element name="Values" minOccurs="0"> 
                    <xs:complexType> 
                     <xs:choice maxOccurs="unbounded"> 
                      <xs:element ref="Doc" minOccurs="0"/> 
                       <xs:element name="Value" minOccurs="1" maxOccurs="unbounded"> 
                       <xs:complexType> 
                        <xs:attribute name="name" type="xs:string" use="required"> 
                         <xs:annotation> 
                          <xs:documentation>Name of the value</xs:documentation> 
                         </xs:annotation> 
                        </xs:attribute> 
                        <xs:attribute name="id" type="xs:string" use="required"> 
                         <xs:annotation> 
                          <xs:documentation>The value</xs:documentation> 
                         </xs:annotation> 
                        </xs:attribute> 
                       </xs:complexType> 
                      </xs:element> 
                     </xs:choice> 
                    </xs:complexType> 
                   </xs:element> 
                  </xs:choice> 
                  <xs:attribute name="encode" type="xs:string" default="hex"> 
                   <xs:annotation> 
                    <xs:documentation>encoding</xs:documentation> 
                   </xs:annotation> 
                  </xs:attribute> 
                 </xs:complexType> 
                </xs:element> 
               </xs:choice> 
              </xs:complexType> 
              <xs:unique name="unique_filed_name"> 
               <xs:selector xpath="Field"/> 
               <xs:field xpath="@name"/> 
              </xs:unique> 
             </xs:element> 
            </xs:choice> 
            <xs:attribute name="name" type="xs:string" use="required"/> 
            <xs:attribute name="type" type="xs:string"/> 
            <xs:attribute name="filter" type="xs:string"/> 
            <xs:attribute name="mask" type="xs:string"/> 
           </xs:complexType> 
          </xs:element> 
         </xs:choice> 
        </xs:complexType> 
        <xs:unique name="unique_parameter_name"> 
         <xs:selector xpath="Parameter"/> 
         <xs:field xpath="@name"/> 
        </xs:unique> 
       </xs:element> 
      </xs:choice> 
      <xs:attribute name="name"> 
       <xs:annotation> 
        <xs:documentation>Unique</xs:documentation> 
       </xs:annotation> 
      </xs:attribute> 
      <xs:attribute name="type" type="MessageTypes" use="required"> 
       <xs:annotation> 
        <xs:documentation>Select a valid type</xs:documentation> 
       </xs:annotation> 
      </xs:attribute> 
     </xs:complexType> 
    </xs:element> 

,我得到這個錯誤沒有意義的,因爲我加了過濾器我的XSD:

元素'Parameter',屬性'filter':屬性'filter'不允許爲 。

任何人都可以幫助我解釋爲什麼我得到這個似乎很難解決的錯誤?

+0

Downvoting,因爲當問題被(部分)回答時你沒有跟進。看起來你有提問的歷史,不承認答案。 –

回答

0

當我貼你的「模式」到一個xs:schema元素,並運行它,我得到

Error at xs:element on line 3 column 69 of test.xsd: 
    Attribute @minOccurs is not allowed on element <xs:element> 
Error at xs:element on line 3 column 69 of test.xsd: 
    Attribute @maxOccurs is not allowed on element <xs:element> 

這表明你的XS:元素並不是一個真正的頂級元素,所以我們不看到整個畫面。

當我解決這個問題,我得到了很多的錯誤,像這樣的:

on line 6 of test.xsd: 
    The element {Doc} is referenced, but has not been declared 
on line 77 of test.xsd: 
    The type {MessageTypes} is referenced, but has not been declared 

當我修復這些錯誤,該實例是在架構上有效。

我只能得出結論,在將您真實的代碼縮減到您發佈的部分時,您會無意中刪除了錯誤的部分。

但我同意該信息沒有意義。你使用什麼XSD處理器?