views:

398

answers:

2

Hello everyone,

I was wondering how I can possible extend XSLT 1.0 so that I can use functions from fn function namespace at http://www.w3schools.com/Xpath/xpath_functions.asp

I was just told that the system is using MSXML XSLT processor from now on. All my stylesheets were written in 2.0 ... So now I'm stack, nothing is working and don't know how I can use functions for example from fn namespace.

I was wondering whether it will be possible to extend XSLT 1.0 somehow, because I use lots of those functions. Or what do I do now? I'm absolutely lost and frustrated.

Would really appreciate any help!

Thanks a lot!

+2  A: 

Well, IMHO, you'r a bit stuck. MSXML, does not implement XSLT 2.0 and XPath 2.0. So basically you are left with three options:

  1. Try to convince you supperiors that they should provide support for another XSLT processor like Saxon.NET.
  2. Reimplement all the functions you need using microsoft's msxsl:script function. This should prove difficult and leaves you with a dependency with the Microsoft parser. Furthermore, it only convers the XPath functions - the XSLT 2.0 functionality is not considered here.
  3. Reimplement your stylesheets using XSLT 1.0.

Personally, I guess that ony option 1 and 3 are feasible.

Obalix
@Obalix Thank you. Unfortinately, they won't change the processor. I was just wondering if I can do anything at all so that I can use functions from http://www.w3schools.com/Xpath/xpath_functions.asp at all? Somehow extend MSXML? Sign. I think I'm in a big pickl.
DashaLuna
Well you can look at http://www.exslt.org/ to see whether there is something you can use, however, unless MS decides to incorporate XSLT 2.0 into ther Processor, you are left alone. But, don't be to donwhearted, I've fallen ito the same trap a while ago.
Obalix
+2  A: 

If you are stuck with MSXML as your processor, I think your only is to go with option 2 in Obalix's answer, but you will probably have to write the extension functions yourself.

Here is an example of how you might do the Upper Case function. This uses javascript within the XSLT to do the function.

<?xml version='1.0'?>
<xsl:stylesheet version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt"
      xmlns:user="http://mycompany.com/mynamespace"&gt;

<msxsl:script language="javascript" implements-prefix="user">
   function uppercase(textToConvert) 
   {
      return textToConvert.toUpperCase();
   }
</msxsl:script>

<xsl:template match="text()">
   <xsl:value-of select="user:uppercase(string(.))"/>
</xsl:template>

</xsl:stylesheet>

What you could do, is put all the script functions in their own XSLT sheet, and include it in all your own XSLT stylesheets.

How complicated this turns out to be, depends on how many XPath2.0 functions you have used.

Tim C
@Tim C thanks a lot. I've noticed you declared msxsl namespace (xmlns:msxsl="urn:schemas-microsoft-com:xslt"). I was wondering if you know a good place to read up on MSXML in general, so I can understand it and figure out what I can use... I would really appreciate it! Thanks!
DashaLuna
I don't know how good it is, but you could try this link to it on MSDN - http://msdn.microsoft.com/en-us/library/ms759204(VS.85).aspx
Tim C