XSLT专业站 - 提供xslt和xml相关的资料书籍和教程  
XSLT专业站 - 提供xslt和xml相关的资料书籍和教程
网站地图  收藏本站
首页 | 热门文章 | 精彩实例 | 经典教程 | XSLT语法详解 | 资料下载 | 休闲天地 | 交流论坛
  当前位置:首页>精彩实例>文章内容
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 实例:统计作者出版物的销量
  精彩实例热点文章
·查找公共祖先节点
·利用 xslt 对 xml 进行缩进格式
·XSLT 实例:创建带有“前一页”
·利用 XSL 解析 RSS
·把数据库输表用 XSLT 转化为树状
·查找节点的父节点
·用 XML/XSL 来生成动态页面
·利用 XSL 对 XML 数据进行加密和
·XSLT 实例:统计作者出版物的销
·XSLT 实例:使用变量(Variable)
  精彩实例相关文章
·XSLT 实例:统计作者出版物的销
·XSLT 实例:创建带有“前一页”
·XSLT 实例:使用变量(Variable)
·利用 XSL 对 XML 数据进行加密和
·利用 xslt 对 xml 进行缩进格式
·用 XML/XSL 来生成动态页面
·查找公共祖先节点
·查找节点的父节点
·把数据库输表用 XSLT 转化为树状
·利用 XSL 解析 RSS
Copyright© 2007 xslt.org.cn All rights reserved.