none
[XSLT] Unable to declare functions RRS feed

  • Question

  • Hello everybody,

    Perhaps there is a specialized forum about XSLT, but I did not find it in the list.

    I am using Visual Studio Pro 15.9.14 to develop an XSLT project based on a .Net 4.7.03190 Windows Form project.

    Is it a bad idea ?

    I should like to use the tokenize function as documented here :

    https://www.w3.org/TR/xquery-xpath-parsing/#xpath20

    but, it seems, not here :

    https://docs.microsoft.com/fr-fr/dotnet/api/system.xml.xsl.runtime.xsltfunctions?view=netframework-4.8

    So my XSLT stylesheet, after the xml declaration, starts with

    <xsl:stylesheet version="2.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:fn="http://www.w3.org/2005/xpath-functions">

    (I copied that from screen to keyboard from another system, but I do not think I made to many errors)

    Well, when I launch the transformation, an exception tells me that it is impossible to find a script or extension object associated with "http://www.w3.org/2005/xpath-functions".

    I tried cheating by putting 3.0 instead of 2.0 in the version number of the stylesheet as I saw somewhere on w3.org that the functions are supported only by version 3, but changing the header is not sufficient.

    Has that to be imported anywhere ? A Nuget package for that perhaps ?

    And ... Yesterday I could not use <apply-templates> in the stylesheet, I obtained a list of recognized tokens, but apply-templates was not in it. This morning I do not have this error. Perhaps I did not use it at the correct place ? Does it have, surprisingly, to be inside another template?

    Supposing we find how to declare that tokenize function, I am hesitant about the syntax to use it.

    For example, to get the content between the second and the third dots in the name attribute :

    <xsl:value-of select="fn:tokenize(@name, '.')[2]"></xsl:value-of>
    Oh, something more : is it possible to put the results in a variable, to apply a <xsl:for-each> on it ?


    • Edited by Gloops Wednesday, September 18, 2019 8:00 AM
    Wednesday, September 18, 2019 7:49 AM

Answers

All replies