开发者

XSL Select value of both attribute AND element

开发者 https://www.devze.com 2023-03-22 22:53 出处:网络
I\'m working on an XSL stylesheet for some XML encoded finding aids. At the detailed description level for the contents of the collection, I have some containers like so:

I'm working on an XSL stylesheet for some XML encoded finding aids. At the detailed description level for the contents of the collection, I have some containers like so:

<container type="folder">1</container>
开发者_JAVA技巧

I need to select both the @type AND the number value in the container, however all I can manage to pull is the number. How should I structure my query to get folder 1?


If current node is container:

<xsl:value-of select="concat(@type, ' ', text())"/>

Input XML:

<container type="folder">1</container>

XSLT:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="container">
        <xsl:value-of select="concat(@type, ' ', text())"/>
    </xsl:template>
</xsl:stylesheet>

Output:

folder 1
0

精彩评论

暂无评论...
验证码 换一张
取 消