XPath部分函数
Node-Set函数

count()、local-name()、name()、position()、last()
String函数

concat()、contains()、starts-with()、string()、string-length()、substring ()、substring-after()、substring-before()、translate()

<xsl:variable name="UpCaseHttp" select="translate($ItemValue, 'htp', 'HTP')"/>
Boolean函数

boolean()、false()、not()、true()
Number函数

ceiling()、floor()、number()、round()、sum()
XSLT标签
xsl:template xsl:call-template xsl:apply-templates xsl:param xsl:with-param

<xsl:template name="JSButton">

<xsl:param name="Name"/>

<xsl:param name="JS"/>







<xsl:value-of select="$Name"/>





</xsl:template>

<xsl:template name="ea:SaveNoNewButton">

<xsl:call-template name="JSButton">

<xsl:with-param name="Name" select="' 保存'"/>

<xsl:with-param name="JS" select="'verify("Save")'"/>

</xsl:call-template>

</xsl:template>

<xsl:apply-templates select="Ebanswers/PAGE">

<xsl:template match="PAGE">

</xsl:template>
xsl:foreach

<xsl:for-each select="$CodeTable">

<option value="{CODE_VALUE}">

<xsl:if test="CODE_VALUE = $AValue">

<xsl:attribute name="selected"/>

</xsl:if>

<xsl:value-of select="CODE_NAME"/>

</option>

</xsl:for-each>
xsl:sort

<xsl:sort

select = string-Expression

lang = { nmtoken }

data-type = { "text" | "number" | QName }

order = { "ascending" | "descending" }

case-order = { "upper-first" | "lower-first" }

/>

紧随xsl:apply-templates或xsl:for-each

<xsl:apply-templates select="/Toolkit/tk:Table/tk:Field[tk:List]">

<xsl:sort select="tk:List/@Order" data-type="number"/>

</xsl:apply-templates>
xsl:variable

注意字符串变量

<xsl:variable name="Test" select="'title'"/>
xsl:value-of xsl:text

<xsl:value-of

select = Expression

disable-output-escaping = "yes" | "no"

</xsl:value-of>

<xsl:text

disable-output-escaping = "yes" | "no">

</xsl:text>

<xsl:template name="ea:WhiteSpace">

<xsl:text disable-output-escaping="yes">&nbsp;</xsl:text>

</xsl:template>
xsl:element xsl:attribute xsl:attribute-set

XML File (item.xml)

<?xml version="1.0"?>

<?xml-stylesheet type="text/xsl" href="element.xsl" ?>

<root>

<item>My Item</item>

</root>

XSLT File (element.xsl)

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

<xsl:template match="item">

<xsl:element name="xsl:template">

<xsl:attribute name="match">cost</xsl:attribute>

<xsl:attribute name="xml:space">preserve</xsl:attribute>

<xsl:apply-templates/>

</xsl:element>

</xsl:template>

</xsl:stylesheet>

Output

This is the formatted output:

My Item

The following is the processor output, with line breaks added for clarity.

<?xml version="1.0"?>

<xsl:template match="cost"

xml:space="preserve"

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

My Item</xsl:template>

<xsl:attribute-set name="ea:WrapAttrs">

<xsl:attribute name="nowrap"/>

</xsl:attribute-set>



<xsl:attribute-set name="ea:NonEmptyAttrs" use-attribute-sets="ea:WrapAttrs">

<xsl:attribute name="align">right</xsl:attribute>

<xsl:attribute name="bgcolor">#E2EBF6</xsl:attribute>

</xsl:attribute-set>
xsl:if xsl:choose xsl:when xsl:otherwise



<xsl:if test="$Target != ''">

<xsl:attribute name="target"><xsl:value-of select="$Target"/></xsl:attribute>

</xsl:if>

<xsl:value-of select="$ItemValue"/>



<xsl:choose>

<xsl:when test="$BigHrefType='HREF'">



<xsl:value-of select="$Value"/>



</xsl:when>

<xsl:when test="$BigHrefType='EMAIL'">



<xsl:value-of select="$Value"/>



</xsl:when>

<xsl:otherwise>

<xsl:call-template name="ea:ProcessText">

<xsl:with-param name="Text" select="$Value"/>

</xsl:call-template>

</xsl:otherwise>

</xsl:choose>
xsl:import xsl:include

<xsl:import href="PublicUtil.xslt"/>
xsl:copy-of xsl:output

<xsl:output method="html" indent="no"/>

<xsl:variable name="ea:NoRecord">



没有内容



</xsl:variable>

<xsl:copy-of select="$ea:NoRecord"/>
XSLT函数

current()

通常情况下,和"."返回的值相同。只有在filter情况下,才不同。

<xsl:apply-templates select="//glossary/item[@name=current()/@ref]"/

document()

<xsl:variable name="ea:FieldList" select="document('')/xsl:stylesheet/ea:FieldList"/>

format-number()

format-number(53.51, "#.0000") // "53.5100"
其他

递归:

<xsl:template name="ea:ProcessText">

<xsl:param name="Text"/>

<xsl:choose>

<xsl:when test="contains($Text,' ')">

<xsl:value-of select="substring-before($Text,' ')"/>




<xsl:call-template name="ea:ProcessText">

<xsl:with-param name="Text" select="substring-after($Text,' ')"/>

</xsl:call-template>

</xsl:when>

<xsl:otherwise>



<xsl:value-of select="$Text"/>



</xsl:otherwise>

</xsl:choose>

</xsl:template>

<xsl:template name="ShowRow">

<xsl:param name="CurIndex" select="0"/>

<xsl:param name="Data"/>

<xsl:param name="CurRow"/>

<xsl:if test="$CurIndex=0">





周历





</xsl:if>

<xsl:if test="$CurIndex < 7">

<xsl:call-template name="ShowData">

<xsl:with-param name="Data" select="$Data"/>

</xsl:call-template>

<xsl:for-each select="$Data">

<xsl:call-template name="ShowRow">

<xsl:with-param name="CurIndex" select="$CurIndex + 1"/>

<xsl:with-param name="Data" select="following-sibling::DateDescription[1]"/>

</xsl:call-template>

</xsl:for-each>

</xsl:if>

</xsl:template>

优先级问题

<xsl:import>存在优先级问题

模糊匹配的,例如*,优先级比较低

属性值模板



More:[http://www.xslt.org.cn/html/grammars/index.html](http://www.xslt.org.cn/html/grammars/index.html)