2016-09-16 60 views
0

额外attibutes我必须保持一个标签在XML通过以下方式联系:XSD创建于标签

<abc> 
    <interaction operation="submit"> 
    <prop> 
     <x> 
     <y> 
    <prop> 
    <interaction> 
<abc> 

的XML也可以有这样的:

<abc> 
    <interaction operation="update"> 
    <prop> 
     <x> 
     <y> 
    <prop> 
    <interaction> 
<abc> 

我创建大部分XSD。现在,您是否知道如何定义交互标签,以便它可以具有操作=“更新”或“提交”值?

+0

请[编辑]您的问题,并通过修复您的结束标记:''等,使您的XML格式良好。谢谢。 – kjhughes

回答

0

您可以通过限制其他类型创建一个新的类型,如xs:string只允许特定的字符串,

<xsd:simpleType name="OperationType"> 
    <xsd:restriction base="xsd:string"> 
    <xsd:enumeration value="update"/> 
    <xsd:enumeration value="submit"/> 
    </xsd:restriction> 
</xsd:simpleType> 

,然后在属性声明引用此类型:

<xs:attribute name="operation" type="OperationType"/>