我需要解析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