我需要解析Visual Studio自动生成的XML文档以创建报告。我决定使用XSLT,但我很新,需要帮助。 常见的模板是:在XSLT中使用RegEx
<doc>
<members>
<member name="F:MyNamespace">
<summary>Some text</summary>
</member>
</members>
</doc>
我要隔离与开始于一些词,例如,P名成员:Interfaces.Core。我决定在select语句中使用RegExp。
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fn="http://www.w3.org/TR/xpath-functions/">
<xsl:template match="/" >
<html xmlns="http://www.w3.org/1999/xhtml">
<body style="font-family:Tahoma">
<p>Interfaces list:</p>
<table>
<xsl:for-each select="doc/members/member">
<xsl:sort order="ascending" />
<xsl:value-of select="fn:matches(., 'P\..+')" />
<br />
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
为什么我得到错误:
Namespace http://www.w3.org/TR/xpath-functions does not contain any functions >
我在哪里错了?我在例子中发现了这样的代码,包括w3c.org!
Abatishchev,看到我的答案。在此时的所有答案中,只有这个答案为您提供了使用的确切XPath表达式。它还讨论了其他可用的选项,演示了使用其他可用的XPath 1.0函数以及如何以XPath 1.0表达式实现ends-with()。干杯 – 2008-12-04 17:27:23