开发者

XSL Select value of both attribute AND element

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜