您可以使用子,后成对子,之前只是提取数
这是表达式
substring-before(substring-after(.,'http://www.mysite.com/Topic/'),'/')
鉴于你输入(我加了一个根节点,使其vaild)
<xml>
<Result>
<Url>http://www.mysite.com/Topic/1/</Url>
</Result>
<Result>
<Url>http://www.mysite.com/Topic/2/</Url>
</Result>
<Result>
<Url>http://www.mysite.com/Topic/3/</Url>
</Result>
</xml>
此转换说明你想
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes" method="xml"/>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="Url">
<Topic>
<xsl:value-of select="substring-before(substring-after(.,'http://www.mysite.com/Topic/'),'/')"/>
</Topic>
</xsl:template>
</xsl:stylesheet>
输出
<xml>
<Result>
<Topic>1</Topic>
</Result>
<Result>
<Topic>2</Topic>
</Result>
<Result>
<Topic>3</Topic>
</Result>
</xml>
结果根据上下文,你应将上述表达式中的.
替换为访问节点所需的路径。
感谢您的全面回答! – Tempered 2011-06-20 14:49:08