2011-07-03 84 views
0

我想声明下一个类型的限制:声明与属性和文本的类型时,由图案

<partCode negation="true|false">\*|[0-9]{1,9}</name> 

与布尔属性,只有文本的内容,由一个图案(*或数字)的限制。

我旁边XSD至今:

<xs:complexType name="partCode"> 
    <xs:simpleContent> 
     <xs:restriction base="xs:string"> 
      <xs:pattern value="\*|[0-9]{1,9}" /> 
     </xs:restriction> 
     <xs:extension base="xs:string"> <-- error 
      <xs:attribute name="negation" type="xs:boolean" use="optional" default="false" /> 
     </xs:extension> 
    </xs:simpleContent> 
</xs:complexType> 

但它包含一个错误:

The 'extension' element already exists in the content model

我怎样才能做到这一点?

回答

0
<xs:complexType name="PartCodeValue"> 
    <xs:simpleContent> 
     <xs:extension base="xs:string"> 
      <xs:attribute name="negation" type="xs:boolean" use="optional" default="false" /> 
     </xs:extension> 
    </xs:simpleContent> 
</xs:complexType> 
<xs:complexType name="PartCode"> 
    <xs:simpleContent> 
     <xs:restriction base="PartCodeValue"> 
      <xs:pattern value="\*|[0-9]{1,9}" /> 
     </xs:restriction> 
    </xs:simpleContent> 
</xs:complexType> 
0

您不能在同一步骤中限制和扩展。首先定义满足该模式的xs:string的限制;然后定义添加属性的扩展名。

+0

请您举个例子,很高兴接受它。 – abatishchev