我通过 XMLSpy 使用以下 XSLT:
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<xsl:output method="xml" version="1.0" encoding="UTF-16" indent="yes"/>
<xsl:template match="*">
<xsl:element name="{lower-case(local-name())}">
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="* | text()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{lower-case(local-name())}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
</xsl:stylesheet>
如果我尝试在我的源代码 (XslCompiledTransform) 中使用它,我会收到一个异常,告诉我函数“lower-case()”不是 XSLT 合成器的一部分。
所以我稍微改变了转换:
fn:lower-case
现在我的异常是无法找到前缀为“http://www.w3.org/2005/xpath-functions”的脚本或外部对象。 这是怎么回事?我该如何解决?
问候
最佳答案
.NET 不实现 XSLT 2.0/XPath 2.0。
在 XPath 1.0 中,可以使用以下表达式代替 lower-case()
:
translate(yourString,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')
关于c# - 使用 .NET 的 XSLT 小写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4125130/