连接多个属性值

Tan*_*gui 7 xpath

提供这种XML文件:

<data> 
    <row val="3"/> 
    <row val="7"/> 
    <row val="2"/> 
    <row val="4"/> 
    <row val="3"/> 
</data>
Run Code Online (Sandbox Code Playgroud)

我需要使用XPath 1.0检索字符串'3; 7; 2; 4; 3',以便我可以在我的XForms应用程序中为Google Chart服务创建动态链接.

我怎样才能做到这一点 ?可能吗 ?

小智 8

XPath 2.0解决方案:

string-join(/data/row/@val,';')
Run Code Online (Sandbox Code Playgroud)

XSLT 1.0解决方案:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text"/>
    <xsl:template match="row">
        <xsl:value-of select="concat(substring(';',1,position()-1),@val)"/>
    </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

编辑:简短的XSLT 1.0解决方案.