Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XSLT lower-case using .NET

Tags:

c#

xslt

i use the following XSLT by using XMLSpy:

<?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>

If i try to use it in my source (XslCompiledTransform) i get an exception telling me that the function 'lower-case()' is not part of the XSLT synthax.

So i changed the transformation a little bit:

fn:lower-case

Now my exception is that the script or external object prefixed by 'http://www.w3.org/2005/xpath-functions' can not be found. Whats the matter here? How can i fix it?

Regards

like image 479
Jaster Avatar asked Nov 08 '10 15:11

Jaster


People also ask

Is XSLT case sensitive?

xslt. The values of the tableName XML element is case insensitive.

Can we use XQuery in XSLT?

You can call any of the MarkLogic Server Built-In XQuery functions from an XSLT stylesheet.

Is XSLT 2.0 backward compatibility?

The XSLT 2.0 engine is backwards compatible. The only time the backwards compatibility of the XSLT 2.0 engine comes into effect is when using the XSLT 2.0 engine to process an XSLT 1.0 stylesheet.


1 Answers

.NET does not implement XSLT 2.0/XPath 2.0.

In XPath 1.0 one can use the following expression, instead of lower-case():

translate(yourString, 
          'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 
          'abcdefghijklmnopqrstuvwxyz')
like image 128
Dimitre Novatchev Avatar answered Sep 22 '22 23:09

Dimitre Novatchev