• xpth xslt


    XPTH

    属性轴:bank/p/name/@first------------选择name的first属性

    祖先轴:ancestor::p--------------选择祖先为p的祖先节点

    祖先自身轴:ancestor-or-self::name选择祖先为name的祖先节点 或者名称为name的本身节点

    后继轴:following::money------------选择当前上下文节点后的所有money节点

    后继兄弟轴:following-sibling::money----------------选择当前上下文节点后的所有兄弟节点中的money节点

    函数

    position()----------------------返回当前节点的位置

    last()--------------------------返回当前上下文节点的数目

    text()--------------------------当前节点的名称

    count()------------------------返回匹配节点的数目

    XSLT

    书写xslt的基本格式

    <?xml version="1.0" encoding="UTF-8"?>

    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />

    </xsl:stylesheet>

    模板,应用模板和命名模板

    <xsl:template match="/bank/p/name">

    实际模板可以理解成for-each语句

    </xsl:template>

    <xsl:apply-template >

    把指定模板应用到当前位置  注意:他还有一个mode--这个属性可以对同样的节点进行不同的处理,很有用

    </xsl:apply-template>

    <xsl:template match="/bank/p/name" name=”moban1”>

    实际模板可以理解成for-each语句

    </xsl:template>

    <xsl:template match="/bank/p/name" name=”moban2”>

    实际模板可以理解成for-each语句

    </xsl:template>

    <xsl:call-template name=”templateName”>

    <xsl:with-param name=”moban1” />

    </xsl:call-template>

    过滤指定节点

    <xsl:if test=”@name &gt; 20”>

    if test=”@name = 20”/if test=”@name &lt; 20”

    <xsl:if>

    <xsl:choose>

    <xsl:when test="name='PHPer'">PHPer就是PHP程序员的意思!</xsl:when>

    <xsl:when test="name='CJ'">好好Coding,天天向上!</xsl:when>

    <xsl:when test="name='DBD'">不懂!</xsl:when> <xsl:otherwise>其它人</xsl:otherwise>

    </xsl:choose>

    排序

    <xsl:for-each select="bank/p/age">
                <xsl:sort select="@age" order="ascending" />
                <hr />
                <xsl:value-of select="text()"/>
    </xsl:for-each>

    函数

  • 相关阅读:
    Android自注-15-Activity生命周期
    【v2.x OGE课程 15】 布局相关
    多线程——继承Thread类别
    Kivy A to Z -- Kivy 示例演示自带名单
    Android Training
    [TypeScript] Configuring a New TypeScript Project
    [TypeScript] Installing TypeScript and Running the TypeScript Compiler (tsc)
    [Redux] Fetching Data on Route Change
    [Redux] Wrapping dispatch() to Log Actions
    [Redux] Normalizing the State Shape
  • 原文地址:https://www.cnblogs.com/nier/p/2512246.html
Copyright © 2020-2023  润新知