XML架构限制? [英] XML schema limitation ?

查看:81
本文介绍了XML架构限制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个模式文件:

base.xsd

 < xs:simpleType name =" PropertyNameType" >

    < xs:restriction base =" xs:string">

      < xs:enumeration value =" UniqueID" />
$
        < xs:enumeration value =" Name" />
$
    < / xs:restriction>

  < / xs:simpleType>

 <xs:simpleType name ="PropertyNameType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="UniqueID" />
        <xs:enumeration value="Name" />
    </xs:restriction>
  </xs:simpleType>

现在如何在A.xsd中将枚举列表添加到相同类型

Now how to add enumerations list to same type in A.xsd

< xs:redefine schemaLocation =" ; base.xsd">

    < xs:simpleType name =" PropertyOutputsNameType">

      < xs:restriction base =" PropertyOutputsNameType">       < xs:enumeration value =" Description" />&NBSP;&NBSP;


        < xs:enumeration value =" Value" />



      < / xs:restriction>

    < / XS:的simpleType>&NBSP;&NBSP;

  < / xs:redefine>

<xs:redefine schemaLocation="base.xsd">
    <xs:simpleType name ="PropertyOutputsNameType">
      <xs:restriction base="PropertyOutputsNameType">
        <xs:enumeration value="Description" />  
        <xs:enumeration value="Value" />

      </xs:restriction>
    </xs:simpleType>  
  </xs:redefine>

粗体文字不起作用,但是:

The bold text is not worked, but :

1)我不想写新类型,因为属性太多了。

1) I dont want to write new type, because the property is so many.

2)在继承的情况下,我想使用'重新定义'功能

2) In scenario of inheritance, I want to use 'redefine' feature

3)但是xml模式的局限性不能从基本简单类型扩展简单类型,只使用限制而不是扩展来添加新枚举

3) But the limitation of xml schema that can not extend simple type from base simple type, only using restriction not extension to add new enumeration

如何解决这个问题?

 

推荐答案

你对重新定义和限制的理解是正确的简单的类型。您无法更改或修改枚举以获得更多值。  您必须创建新类型,或将其他值移动到原始类型。 

Well you are correct in your understanding of redefine and the limitations of simple type. You cannot change or modify an enumeration to have more values regardless.  You will have to create a new type, or move the additional values into the original. 


这篇关于XML架构限制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆