Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function "fn:encode-for-uri" causes XSLT to error

Tags:

xml

xslt

I need to URL Encode a string in XSLT but the function:

fn:encode-for-uri

breaks the script. I checked it out online and apparently it's part of the namespace

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

So i added the following line to the top of my XSLT file to no avail.

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

Any ideas? I stepped through it in Visual Studio and I got the exception:

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

Any ideas?

-Ev

like image 960
Ev. Avatar asked Dec 22 '22 21:12

Ev.


1 Answers

Visual Studio uses a .NET XSLT processor -- that is XSLT 1.0 processor.

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

In order to use this function you need an XSLT 2.0 processor, such as Saxon.NET or XQSharp.

like image 148
Dimitre Novatchev Avatar answered Jan 06 '23 00:01

Dimitre Novatchev