2013-02-26 69 views
1

我想在XSD从xs:stringName属性的类型更改为xs:int,像下面XSD - 可以改变属性类型的扩展型

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
     xmlns="http://www.my.own/2013/XMLSchema"> 

    <xs:complexType name="AType"> 
     <xs:attribute name="Name" type="xs:string" use="required" /> 
    </xs:complexType> 

    <xs:complexType name="BType"> 
     <xs:complexContent> 
      <xs:extension base="AType"> 
       <xs:sequence> 
        <xs:choice> 
         <xs:element name="Content" type="xs:string"/> 
        </xs:choice> 
       </xs:sequence> 
       <xs:attribute name="Name" type="xs:int" use="required"/> 
      </xs:extension> 
     </xs:complexContent> 
    </xs:complexType> 
</xs:schema> 

这是XSD有效吗?如果不是,是否存在其他解决方案来更改属性的类型?

+2

是'Nane'在基础'ATTY'错字? – SparKot 2013-02-26 11:35:38

+0

你的问题是什么可以改变或是否有效? – chiru 2013-02-26 13:38:32

+0

1.错字固定。 2.其实我对这两个问题的答案都感兴趣 – CAMOBAP 2013-02-26 13:47:40

回答

1

不,类型派生的原则是,如果您从基类型派生新类型,派生类型的实例仍必须是基类型的有效实例。所以你不能将一个属性从字符串改为int。

+0

冷,请提供链接到支持您的文字的文档? – CAMOBAP 2013-02-26 18:58:57

+1

您违反了http://www.w3.org/TR/xmlschema-1/#cos-ct-extends的第1.2条款 – 2013-02-26 21:15:05