编辑:添加键.
嗨,
我有一个xml架构,其中包含以下类型:
<xs:complexType name="definition">
<xs:sequence/>
<xs:attribute name="id"/>
</xs:complexType>
<xsd:key name="definitionId">
<xsd:selector xpath="definition"/>
<xsd:field xpath="@id"/>
</xsd:key>
<xs:complexType name="elem">
<xs:sequence>
<xs:element name="entry1" type="elem" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="entry2" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="ref" type="xs:string" use="required"/>
</xs:complexType>
Run Code Online (Sandbox Code Playgroud)
这允许类似于:
<definition id="A">
<definition id="B">
<definition id="C">
<entry1 ref="A">
<entry1 ref="B">
<entry1 ref="C"/>
<entry2/>
</entry1>
<entry1 ref="C">
</entry1>
</entry1>
Run Code Online (Sandbox Code Playgroud)
我需要一个XPath选择器来声明ref属性的keyref,但我不知道如何定义递归路径.
<xsd:keyref name="definitionRef" refer="definitionId">
<xsd:selector xpath="???"/> <<<how to find all "ref" of entry1 ?
<xsd:field xpath="@ref"/>
</xsd:keyref>
Run Code Online (Sandbox Code Playgroud)
谢谢你的时间.
jas*_*sso 13
<xsd:selector>支持受限制的XPath表达式.只child允许使用axis,但XPath表达式可以从这里开始,.//因此您可以使用递归表达式.//entry1
有关更多详细信息,请参阅规范:http://www.w3.org/TR/xmlschema-1/#c-selector-xpath
该<xsd:selector>元素包含一个XML路径语言(XPath)表达式,指定了一组元素,其中由field指定的值必须是唯一的,因此它不应引用属性ref.<xsd:field>element(s)指的是在该集合中应该唯一的值,因此它应该引用属性ref(fields如果需要具有唯一的值组合,则应引用其他值的其余值).
| 归档时间: |
|
| 查看次数: |
17221 次 |
| 最近记录: |