使用.NET的XSLT小写

Jas*_*ter 5 c# xslt

我使用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>
Run Code Online (Sandbox Code Playgroud)

如果我尝试在我的源代码中使用它(XslCompiledTransform),我会得到一个异常,告诉我函数'lower-case()'不是XSLT synthax的一部分.

所以我改变了一点转变:

fn:lower-case
Run Code Online (Sandbox Code Playgroud)

现在我的例外是找不到以'http://www.w3.org/2005/xpath-functions'为前缀的脚本或外部对象.这件事怎么回事?我该如何解决?

问候

Dim*_*hev 5

.NET不实现XSLT 2.0 / XPath 2.0。

在XPath 1.0中,可以使用以下表达式代替lower-case()

translate(yourString, 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
          'abcdefghijklmnopqrstuvwxyz')
Run Code Online (Sandbox Code Playgroud)