2013-11-01 31 views
0

我在我的XSD中定義了一個元素「檢查」,並且它有一個類型爲「int」的屬性「step」。我想要做的是要求第一個「輸入」具有step = 1,下一個具有step = 2,依此類推。這在XSD中可能嗎?我的XSD如何要求屬性值是連續的?

XML架構提取物:

<element name="inspection"> 
    <complexType> 
     <!-- some elements --> 
     <!-- other attributes --> 
     <attribute name="step" type="int"> 
      <simpleType> 
       <restriction> 
        <minInclusive value="1" /> 
       </restriction> 
      </simpleType> 
     </attribute> 
    </complexType> 
</element> 

回答

1

有可能在XSD 1.1,但不是在XSD 1.0。

在XSD 1.1,您可以編寫約束作爲

<xs:assert test="every $i in 1 to count(input) 
       satisfies input[$i]/@step = $i"/> 

這種約束將出現在輸入元素的父元素。

XSD 1.1目前在Xerces和Saxon中實施。