Xml XSLT:使用引用元素的值
我想获取一个元素的值,该元素由另一个元素通过唯一id引用。例如:Xml XSLT:使用引用元素的值,xml,xslt,xpath,xslt-2.0,Xml,Xslt,Xpath,Xslt 2.0,我想获取一个元素的值,该元素由另一个元素通过唯一id引用。例如: <when xml:id="TLI_2" interval="7.683988796743416" since="#T_START"/> <annotationBlock who="#H-F" start="#TLI_2" end="#TLI_3"> <u xml:id="Ladida"><incident> <desc>TiH</desc>
<when xml:id="TLI_2" interval="7.683988796743416" since="#T_START"/>
<annotationBlock who="#H-F" start="#TLI_2" end="#TLI_3">
<u xml:id="Ladida"><incident>
<desc>TiH</desc>
</incident><w xml:id="wd1e235">das</w><w xml:id="wd1e237">war</w><w
xml:id="wd1e239">die</w><w xml:id="wd1e241">erste</w><w xml:id="wd1e243"
>große</w><w xml:id="wd1e245">liebe</w><incident>
<desc>schnitt</desc>
</incident></u>
</annotationBlock>
非常感谢你的帮助 假设您想通过其
xml:id
属性值选择when
元素,那么您可以在w
元素的上下文中使用when
属性值来选择id(祖先::annotationBlock/@start/substring(,2))
选择when
元素,当然还有id(祖先::annotationBlock/@start/substring(,2))/@interval
选择其interval
属性
在模板中使用它的一种简洁方法是在属性值模板中使用它
<xsl:template match="annotationBlock/u/w">
<when interval="{id(ancestor::annotationBlock/@start/substring(., 2))/@interval}">
<xsl:template match="annotationBlock/u/w">
<when interval="{id(ancestor::annotationBlock/@start/substring(., 2))/@interval}">