选择指定指定子节点
<xsl:value-of select="format-number(/xxx/AnnualIncomeDetail[position()=last()]/Sales, '#,###')"/>
1. 批量替换
批量替换FAP/Content/Document/Properties/body内容里边的</Ticker>info</Ticker>
<?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"/>
<xsl:template match="/">
<xsl:variable name="body"><xsl:apply-templates select="FAP/Content/Document/Properties/body"/></xsl:variable>
.....
</xsl:template>

<xsl:template match="FAP/Content/Document/Properties/body">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="Ticker">
<xsl:text/><a href="http://quote.morningstar.com/Switch.html?ticker=<xsl:value-of select="."/>"><xsl:value-of select="."/></a><xsl:text/>
</xsl:template>
</xsl:stylesheet>

2. 把<![CDATA[ asdf<p> cdb </p> name's <ticker>ticker</ticker>...]]>格式化
由于字符中包括了'或",因此无法通过外部的JS来转化(无法把这些内容当成字符串发给JS)。
用没有引号的JS实现
<xsl:stylesheet xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" method="html" media-type="text/html" indent="no" encoding="iso8859-1"/>
<xsl:template match="/">
<script language="Javascript"><xsl:comment><![CDATA[
function format(description)
{
var re=/</g;
var descriptStr=description.replace(re,"<");
re=/>/g;
descriptStr=descriptStr.replace(re,">");
re=/&/g;
descriptStr=descriptStr.replace(re,"&");
re=/""/g;
descriptStr=descriptStr.replace(re,'"');
re=/"/g;
descriptStr=descriptStr.replace(re,"'");
re=/'/g;
descriptStr=descriptStr.replace(re,"'");
document.write(descriptStr);
}
]]></xsl:comment></SCRIPT>
<xsl:template match="Fund/Content/FundFamilyFiduciaryGrade/DirectorIndependence">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="ticker">
<a><xsl:attribute name="href"><xsl:choose>
<xsl:when test="/Fund/Footer/HostServer[. != 'online.morningstar.com']">
http://quote.morningstar.com/Switch.html?ticker=<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
/quote/Switch.html?ticker=<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute><script>caseConvert('<xsl:value-of select="."/>')</script></a>
</xsl:template>
<xsl:template match="text()">
<script>format('<xsl:value-of select="." />')</script>
</xsl:template>
</xsl:stylesheet>
非JS方式
<xsl:stylesheet xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output omit-xml-declaration="yes" method="html" media-type="text/html" indent="no" encoding="iso8859-1"/>
<xsl:template match="/">
<xsl:template match="Fund/Content/FundFamilyFiduciaryGrade/DirectorIndependence">
<xsl:apply-templates />
</xsl:template>
<xsl:template match="ticker">
<a><xsl:attribute name="href"><xsl:choose>
<xsl:when test="/Fund/Footer/HostServer[. != 'online.morningstar.com']">
http://quote.morningstar.com/Switch.html?ticker=<xsl:value-of select="."/>
</xsl:when>
<xsl:otherwise>
/quote/Switch.html?ticker=<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:attribute><script>caseConvert('<xsl:value-of select="."/>')</script></a>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="." disable-output-escaping="yes"/>
</xsl:template>
</xsl:stylesheet>

3. 匹配替换
<xsl:template name="StringReplace">
<xsl:param name="SrcString"/>
<xsl:param name="FromString"/>
<xsl:param name="ToString"/>
<xsl:choose>
<xsl:when test="contains($SrcString,$FromString)">
<xsl:value-of select="substring-before($SrcString,$FromString)" disable-output-escaping="yes"/>
<xsl:value-of select="$ToString" disable-output-escaping="yes"/>
<xsl:call-template name="StringReplace">
<xsl:with-param name="SrcString" select="substring-after($SrcString,$FromString)"/>
<xsl:with-param name="FromString" select="$FromString"/>
<xsl:with-param name="ToString" select="$ToString"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$SrcString" disable-output-escaping="yes"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
Test
1.xsl
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional" xmlns:ms="urn:anything">
<xsl:output omit-xml-declaration="yes" method="html" media-type="text/html" indent="no" encoding="iso8859-1"/>
<xsl:template name="StringReplace">
<xsl:param name="SrcString"/>
<xsl:param name="FromString"/>
<xsl:param name="ToString"/>
<xsl:choose>
<xsl:when test="contains($SrcString,$FromString)">
<xsl:value-of select="substring-before($SrcString,$FromString)"/>
<xsl:value-of select="$ToString"/>
<xsl:call-template name="StringReplace">
<xsl:with-param name="SrcString" select="substring-after($SrcString,$FromString)"/>
<xsl:with-param name="FromString" select="$FromString"/>
<xsl:with-param name="ToString" select="$ToString"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise><xsl:value-of select="$SrcString"/></xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="/">
<xsl:variable name="Tmp">
<xsl:call-template name="StringReplace">
<xsl:with-param name="SrcString" select="/Fund/t1"/>
<xsl:with-param name="FromString" select="string('t123')"/>
<xsl:with-param name="ToString" select="string('')"/>
</xsl:call-template>
</xsl:variable>
<xsl:call-template name="StringReplace">
<xsl:with-param name="SrcString" select="$Tmp"/>
<xsl:with-param name="FromString" select="string('t456')"/>
<xsl:with-param name="ToString" select="string('')"/>
</xsl:call-template>
</xsl:template>

</xsl:stylesheet>
1.xml
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="1.xsl"?>
<Fund><t1>
t456t123's &t1200t456700
</t1></Fund>