简体   繁体   English

用于获取最后一个元素的属性值的XSLT代码

[英]XSLT code to get the value of an attribute of the last element

I am XSLT beginner and have an XML with the connections tags as mentioned below .. 我是XSLT初学者,并且有一个带有连接标记的XML,如下所述。

This is my XML: 这是我的XML:

<connections sourceElement="/3/@elements.2" targetElement="/3/@elements.0" schemaName="Target_Query"/> 
<connections sourceElement="/3/@elements.1" targetElement="/3/@elements.3" schemaName="R3_DF_PRODUCT"/> 
<connections sourceElement="/3/@elements.3" targetElement="/3/@elements.2" schemaName="Transform3"/>

And I want to iterate through the connections and get only the last one 我想迭代连接并获得最后一个连接

//dataflow:DataFlow/connections 

(which @targetElement isn't used as @SourceElement in other <connections> ). (这@targetElement未用作@SourceElement在其他<connections> )。
I need to get the value of @schemaName . 我需要获得@schemaName的值。

Can any body help with the sample snippets to achieve this? 任何人都可以帮助使用样本片段来实现这一目标吗?

To get the schemaName attribute of the last connections element, you can use the following XPath-1.0 expression: 要获取最后一个connections元素的schemaName属性,可以使用以下XPath-1.0表达式:

//dataflow:DataFlow/connections[last()]/@schemaName

IN XSLT it can be accessed with 在XSLT中,可以使用它进行访问

<xsl:value-of select="//dataflow:DataFlow/connections[last()]/@schemaName"/>

Output is: 输出是:

Transform3 Transform3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM