【问题标题】:XSD: What does the "name" attribute mean for the "anyAttribute" element?XSD:“name”属性对“anyAttribute”元素意味着什么?
【发布时间】:2011-12-06 21:39:44
【问题描述】:

我目前正在阅读BPMN 2.0 的规范。在本规范中,BPMN 各部分的定义以 XML 模式的形式给出。

在其中一个模式中(表 8.3,第 54 页),我偶然发现了对我来说没有意义的一行:

<xsd:element name="definitions" type="tDefinitions"/>
  <xsd:complexType name="tDefinitions">
  ...
    <xsd:anyAttribute name="exporter" type="xsd:ID"/>
  ...

让我感到困惑的是“name”属性与“xsd:anyAttribute”元素的结合使用。如果我正确理解了元素的definition,其目的是允许使用架构未指定的“未知”属性。那么将“xsd:anyAttribute”限制为具体名称“exporter”而不是直接指定具有该名称的(可选)属性的目的是什么?

【问题讨论】:

  • 仔细检查实际的架构文件。这可能是文档中的错误。

标签: xml xsd bpmn


【解决方案1】:

这可能只是文档中的一个错误,他们缩进使用xsd:attribute声明一个属性。

xsd:anyAttribute 没有@name

<anyAttribute
  id = ID
  namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )  : ##any
  processContents = (lax | skip | strict) : strict
  {any attributes with non-schema namespace . . .}>
  Content: (annotation?)
</anyAttribute>

【讨论】:

  • 感谢您的确认!这也是我的印象,但我不确定这是否只是我对 XSD 理解不足的问题。 ;-)
  • 刚刚发现OMG网站上给出的XML Schemas居然用xsd:attribute而不是xsd:anyAttribute!所以@Mads,你完全正确,这是规范文档中的一个错误。
  • 酷。您应该向发布者发送注释,提醒他们注意错误,以便他们修复并发布更正的文档。
  • 好建议!我向 OMG 报告了这个错误。
  • anyAttribute 不起作用,请参阅stackoverflow.com/q/14872678/306488
【解决方案2】:

anyAttribute 元素使作者能够使用架构未指定的属性来扩展 XML 文档。

来源:http://www.w3schools.com/schema/el_anyattribute.asp

这里有你需要知道的一切!您必须将这个 anyAttribute 视为通配符。

【讨论】:

  • 正如我的问题中所写,我阅读了“anyAttribute”的这个定义,我很困惑,因为它没有为元素指定“名称”属性。
  • 是的,它为您的 XML 空间提供了任何属性,就像我告诉您的那样,您可以将它用作通配符。所以属性 X 或 Y 没关系!
猜你喜欢
  • 1970-01-01
  • 2011-11-29
  • 2015-12-24
  • 2011-01-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-11-04
  • 2011-12-28
相关资源
最近更新 更多