|
XSLT 实例:使用不同的轴(Axis)
|
|
| |
|
来源:XSLT.org.cn 作者:XSLT专业站 发布时间:2007-10-27
|
|
XSLT 实例:使用不同的轴(Axis)
本例展示轴(Axis)的用法
使用到的XSLT元素:xsl:stylesheet xsl:template xsl:apply-templates xsl:call-template xsl:value-of
使用到的XSLT/XPath函数:count
XML:
<?xml version="1.0"?> <book> <chapter title="The sequel" xmlns:annotation="http://some.annotation.com/namespace/"> <annotation:para title="Paragraph"/> <para title="Yet another paragraph" annotation:referral="Tom Sawyer"/> <para title="Last paragraph"/> </chapter> </book> |
XSLT:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <Overview>Overview of numbers of nodes on all axes <xsl:apply-templates select="@*|node()"/> </Overview> </xsl:template> <xsl:template match="@*|node()"> <xsl:call-template name="axes-summary"/> <xsl:apply-templates select="@*|node()"/> </xsl:template> <xsl:template name="axes-summary"> name(): <xsl:value-of select="name()"/> local-name(): <xsl:value-of select="local-name()"/> namespace-uri(): <xsl:value-of select="namespace-uri()"/> Axis self: <xsl:value-of select="count(self::*)"/> Axis child: <xsl:value-of select="count(child::*)"/> Axis descendant: <xsl:value-of select="count(descendant::*)"/> Axis ancestor: <xsl:value-of select="count(ancestor::*)"/> Axis preceding-sibling: <xsl:value-of select="count(preceding-sibling::*)"/> Axis following-sibling: <xsl:value-of select="count(following-sibling::*)"/> Axis attribute: <xsl:value-of select="count(attribute::*)"/> Axis preceding: <xsl:value-of select="count(preceding::*)"/> Axis following: <xsl:value-of select="count(following::*)"/> Axis namespace: <xsl:value-of select="count(namespace::*)"/> </xsl:template> </xsl:stylesheet> |
标题: XSLT 实例:使用不同的轴(Axis)
关键字:轴 Axis XSLT元素 XSLT/XPath函数
|
| 上一篇:XSLT 语法详解: xsl:attribute-set 下一篇:XSLT 实例:统计作者出版物的销量 |
|
|
|
|
|