【发布时间】:2014-09-08 22:16:29
【问题描述】:
我正在尝试编写用于 XML 检查的 XML Schema (XSD)。有一个包含枚举值和子元素的元素。它的格式很奇怪,但被 xml 接受。
Can a XML element contain text and child elements at the same time?
我的情况:
<tree>
<node> enumeration Text (Text only allows "a", "b" and "c")
<subnode1 attribute1="xx"> optional text1 </subnode1>
</node1>
</tree>
我正在尝试编写 xml 架构 (XSD) 来验证格式。所需元素 node1 具有具有三个受限值的 Text。当 text 的值等于“c”时,它还会在其中包含一个 subnode1。
例如,架构会通过以下情况:
<node1>a</node1>
或
<node1>b</node1>
或
<node1>c
<subnode1 attribute1="1">what ever you what</subnode1>
</node1>
但是,它不会通过:
<node1>d</node1>
或
<node1>c</node1>
因为 subnode1 是值“c”所必需的
如何编写带有枚举和子元素的 XML Schema 元素?
【问题讨论】:
-
你的问题是什么,你的 xsd 在哪里?
-
抱歉描述不清楚。我的问题是如何实现给定 xml 的架构及其要求。
标签: xml xsd schema enumeration