Guest chris_almond79 Posted June 22, 2006 Share Posted June 22, 2006 chris_almond79@lycos.comHi all, thanks to whoever is taking the time to read this...I'm trying to get xsl:function working, but I can't seem to find out how to use it.I have found numerous examples an now know how to use the syntax, but what I can't find is how/where to actually define/use the function.I found the attached function at http://www.stylusstudio.com/docs/v2006/d_xslt87.htmlBut when I save it, either as a .xml or .xsl file, and open it in Internet Explorer, I just get IE's default representation of a standard xml file. That is, I see the code, not the results of running the function.So how is xsl:function actually used?Do I need an XML file and an XSL file? or can everything be included in the one file as below?Do I HAVE to run it from a web server (eg: http://localhost/) or can it be run straight from my C drive?How can I confirm that I have version 2.0 of XSL?Is this example even valid?Thanks in advance for any advice anyone can give me,Chris. <xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:str="http://example.com/namespace" version="2.0" exclude-result-prefixes="str"> <xsl:function name="str:reverse" as="xs:string"> <xsl:param name="sentence" as="xs:string"/> <xsl:sequence select="if (contains($sentence, ' ')) then concat(str:reverse(substring-after($sentence, ' ')), ' ', substring-before($sentence, ' ')) else $sentence"/></xsl:function> <xsl:template match="/"><output> <xsl:value-of select="str:reverse('DOG BITES MAN')"/></output></xsl:template> </xsl:transform> Link to comment Share on other sites More sharing options...
boen_robot Posted June 22, 2006 Share Posted June 22, 2006 xsl:function is an XSLT 2.0 feature. NONE of today's browsers nor their next versions would support it, because XSLT 2.0 is still a candidate reccomendation. Therefore, I suggest you forget about it for now. If you need it, then try to find XSLT 1.0 solution or find a server side scripting parser (such as Saxon) which supports XSLT 2.0. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now