The fn: encode-for-uri function raises an XSLT error

I need the URL Encode string in XSLT, but the function:

fn:encode-for-uri 

breaks the script. I checked it online and it seems to be part of the namespace

 http://www.w3.org/2005/xpath-functions 

So, I added the following line to the beginning of my XSLT file to no avail.

 xmlns:fn="http://www.w3.org/2005/xpath-functions" 

Any ideas? I went through it in Visual Studio and I got an exception:

 Cannot find a script or an extension object associated with namespace 'http://www.w3.org/2005/xpath-functions'. 

Any ideas?

-ev

+4
source share
2 answers

Visual Studio uses the .NET XSLT processor - it is an XSLT 1.0 processor.

The encode-for-uri () function is a standard function only in XPath 2.0 / XQuery . XSLT 1.0 processors use XPath 1.0, and the encode-for-uri() function is not implemented and is available.

To use this feature, you need an XSLT 2.0 processor such as Saxon.NET or XQSharp.

+9
source
  <xsl:value-of select="encode-for-uri(...)"/> 
+2
source

All Articles