【问题标题】:xml traduce IDREFS in xml schemaxml traduce xml 架构中的 IDREFS
【发布时间】:2018-04-15 05:46:03
【问题描述】:

我需要知道是否有一种方法可以在不使用 IDREFS 类型的情况下在 XML 模式中创建类似但比 IDREFS 更强大的东西。我需要一个 keyref 列表的属性。

  1. 我定义了一个键
  2. 我定义了一个keyref
  3. 现在如何进行?我需要定义一个属性,它是一种 keyref 列表

例子:

 myAttribute = "keyref1 keyref2 keyref3 ..." and so on

记住:使用 IDREFS,我无法创建引用项目的列表。

【问题讨论】:

    标签: xml key keyref


    【解决方案1】:

    不,很遗憾,keyrefs 只能选择节点,而不是节点值中的标记。

    要实现这种约束,您可以使用 XSD 1.1 断言:

    <xs:element name="employees">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="employee" maxOccurs="unbounded"/>
        </xs:sequence>
    
        <xs:assert test="every $id in employee/direct-reports/tokenize(., ' ') 
                         satisfies exists(employee[id=$id])"/>
      </xs:complexType>
    </xs:element>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-20
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多