Re: Adding EXSLT functions
Although not exactly the same way, but you can still call Java code from XSLTs with Saxon HE 9.x. See for example: https://github.com/alveolo/butterfly/tree/master/saxon/src/main/java/org/alveolo/butterfly/saxon/xpath On 28 Feb 2014, at 19:15, gelo1234 wrote: > The problem with 9.x HE Saxon release is also with calling Java functions > from XSLT. If you want that functionality, you either have to buy EE/PE > release or downgrade to older Saxon (7.x/8.x) which works fine with Java/EXSL > functions.
Re: Adding EXSLT functions
Chris, one more notice. Take a look at: http://saxonica.com/documentation9.4-demo/html/extensions/exslt.html EXSLT are available "out of the box" in Saxon 9.x EE/PE, you don't have to include any exsl.xsl additionally. The problem is with Saxon HE, which is by default used in C3 (2.2?). The problem with 9.x HE Saxon release is also with calling Java functions from XSLT. If you want that functionality, you either have to buy EE/PE release or downgrade to older Saxon (7.x/8.x) which works fine with Java/EXSL functions. Greetings, Greg 2014-02-28 17:53 GMT+01:00 gelo1234 : > Hi, > > We have used EXSLT in C2 stylesheets without problems. > Here is an excerpt: > > http://www.w3.org/1999/XSL/Transform"; > version="1.0" xmlns:exslt="http://exslt.org/common";> > ... > > test="exslt:node-set($content)/checkboxes/checkbox[not(@selected)]"> > ... > > As far as memory serves, it worked seamlessly with Xalan and Saxon. > > Greetings, > Greg > > > > 2014-02-28 13:12 GMT+01:00 Ellis Pritchard : > > Hi Chris, >> >> Not standard EXSLT functions, but I have loaded extension functions under >> 2.1. >> >> I've just consulted my archives (2006!)... >> >> Firstly, I used a .xweb patch file patch Cocoon's servlet configuration, >> in order to pre-load my extension classes using Cocoon's load-class >> init-param; this was because doing it lazily at run-time created a >> class-loader race-condition under high load, which caused a random >> extension class to be called on production, and thus randomly fail with a >> NoSuchMethod exception, which was perplexing to say the least (so I mention >> this so you don't have the same problem!): >> >> >> > xpath="/web-app/servlet[servlet-name='Cocoon']/init-param[param-name='load-class']/param-value" >> remove="/web-app/servlet[servlet-name='Cocoon']/init-param[param-name='load-class']/param-value/text()" >> > >> >> com.xxx.xml.exslt.Dates >> com.xxx.xml.exslt.FileUtils >> >> >> etc. >> >> This goes into cocoon's src/confpatch directory as e.g. load-class.xweb >> and patches web.xml, unless you build it some other way. >> >> Then you just write a simple POJO with static methods to do your >> functionality, e.g. I had a little function for finding a local file-size: >> >> package com.xxx.xml.exslt; >> >> import java.io.File; >> >> public class FileUtils { >> >> /** >> * returns the size of a file rounded to the nearest Kilobyte. >> * @param fileName >> * @return the file size in KB, or 0 if file not accessible. >> */ >> public static long Size(String fileName) { >> File file = new File(fileName); >> return ((file.length()+512)/1024); >> } >> } >> >> Then to use this from the XSL, you just declare a namespace with the full >> class name as the URI, and use the prefix and method name as you would use >> any other function e.g.: >> >> >> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; >> xmlns:file="com.xxx.xml.exslt.FileUtils"> >> >> >> Size = >> >> >> >> >> Hope that works for you: it's been a long long time since I did anything >> Cocoony... >> >> Ellis. >> >> On 27 Feb 2014, at 21:47, Christopher Schultz < >> ch...@christopherschultz.net> wrote: >> >> > Signed PGP part >> > All, >> > >> > I've been successfully using EXSLT functions -- specifically, the >> > date-and-time functions (http://exslt.org/date/index.html) -- for some >> > years now and I was interested in using the "seconds" function. It >> > turns out that the "seconds" function is not in the core functions and >> > so for whatever reason, it's not been included in Xalan (I'm using >> > Cocoon 2.1.11 which uses Xalan 2.7.1 by default). >> > >> > I've tried to download and use the date.seconds.xsl template and >> > included Javascript and MSXML XSL templates with a mixture of >> > and xmlns:date declarations, but nothing seems to get the >> > two working together. >> > >> > Has anyone ever manually-plugged an EXSLT function into Xalan? How did >> > you do it? >> > >> > Thanks, >> > -chris >> > >> > >> > - >> > To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >> > For additional commands, e-mail: users-h...@cocoon.apache.org >> > >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org >> For additional commands, e-mail: users-h...@cocoon.apache.org >> >> >
Re: Adding EXSLT functions
Hi, We have used EXSLT in C2 stylesheets without problems. Here is an excerpt: http://www.w3.org/1999/XSL/Transform"; version="1.0" xmlns:exslt="http://exslt.org/common";> ... ... As far as memory serves, it worked seamlessly with Xalan and Saxon. Greetings, Greg 2014-02-28 13:12 GMT+01:00 Ellis Pritchard : > Hi Chris, > > Not standard EXSLT functions, but I have loaded extension functions under > 2.1. > > I've just consulted my archives (2006!)... > > Firstly, I used a .xweb patch file patch Cocoon's servlet configuration, > in order to pre-load my extension classes using Cocoon's load-class > init-param; this was because doing it lazily at run-time created a > class-loader race-condition under high load, which caused a random > extension class to be called on production, and thus randomly fail with a > NoSuchMethod exception, which was perplexing to say the least (so I mention > this so you don't have the same problem!): > > > xpath="/web-app/servlet[servlet-name='Cocoon']/init-param[param-name='load-class']/param-value" > remove="/web-app/servlet[servlet-name='Cocoon']/init-param[param-name='load-class']/param-value/text()" > > > > com.xxx.xml.exslt.Dates > com.xxx.xml.exslt.FileUtils > > > etc. > > This goes into cocoon's src/confpatch directory as e.g. load-class.xweb > and patches web.xml, unless you build it some other way. > > Then you just write a simple POJO with static methods to do your > functionality, e.g. I had a little function for finding a local file-size: > > package com.xxx.xml.exslt; > > import java.io.File; > > public class FileUtils { > > /** > * returns the size of a file rounded to the nearest Kilobyte. > * @param fileName > * @return the file size in KB, or 0 if file not accessible. > */ > public static long Size(String fileName) { > File file = new File(fileName); > return ((file.length()+512)/1024); > } > } > > Then to use this from the XSL, you just declare a namespace with the full > class name as the URI, and use the prefix and method name as you would use > any other function e.g.: > > > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; > xmlns:file="com.xxx.xml.exslt.FileUtils"> > > > Size = > > > > > Hope that works for you: it's been a long long time since I did anything > Cocoony... > > Ellis. > > On 27 Feb 2014, at 21:47, Christopher Schultz < > ch...@christopherschultz.net> wrote: > > > Signed PGP part > > All, > > > > I've been successfully using EXSLT functions -- specifically, the > > date-and-time functions (http://exslt.org/date/index.html) -- for some > > years now and I was interested in using the "seconds" function. It > > turns out that the "seconds" function is not in the core functions and > > so for whatever reason, it's not been included in Xalan (I'm using > > Cocoon 2.1.11 which uses Xalan 2.7.1 by default). > > > > I've tried to download and use the date.seconds.xsl template and > > included Javascript and MSXML XSL templates with a mixture of > > and xmlns:date declarations, but nothing seems to get the > > two working together. > > > > Has anyone ever manually-plugged an EXSLT function into Xalan? How did > > you do it? > > > > Thanks, > > -chris > > > > > > - > > To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org > > For additional commands, e-mail: users-h...@cocoon.apache.org > > > > > - > To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org > For additional commands, e-mail: users-h...@cocoon.apache.org > >
Re: Adding EXSLT functions
Hi Chris, Not standard EXSLT functions, but I have loaded extension functions under 2.1. I’ve just consulted my archives (2006!)… Firstly, I used a .xweb patch file patch Cocoon’s servlet configuration, in order to pre-load my extension classes using Cocoon's load-class init-param; this was because doing it lazily at run-time created a class-loader race-condition under high load, which caused a random extension class to be called on production, and thus randomly fail with a NoSuchMethod exception, which was perplexing to say the least (so I mention this so you don’t have the same problem!): com.xxx.xml.exslt.Dates com.xxx.xml.exslt.FileUtils etc. This goes into cocoon's src/confpatch directory as e.g. load-class.xweb and patches web.xml, unless you build it some other way. Then you just write a simple POJO with static methods to do your functionality, e.g. I had a little function for finding a local file-size: package com.xxx.xml.exslt; import java.io.File; public class FileUtils { /** * returns the size of a file rounded to the nearest Kilobyte. * @param fileName * @return the file size in KB, or 0 if file not accessible. */ public static long Size(String fileName) { File file = new File(fileName); return ((file.length()+512)/1024); } } Then to use this from the XSL, you just declare a namespace with the full class name as the URI, and use the prefix and method name as you would use any other function e.g.: http://www.w3.org/1999/XSL/Transform"; xmlns:file=“com.xxx.xml.exslt.FileUtils”> Size = Hope that works for you: it’s been a long long time since I did anything Cocoony... Ellis. On 27 Feb 2014, at 21:47, Christopher Schultz wrote: > Signed PGP part > All, > > I've been successfully using EXSLT functions -- specifically, the > date-and-time functions (http://exslt.org/date/index.html) -- for some > years now and I was interested in using the "seconds" function. It > turns out that the "seconds" function is not in the core functions and > so for whatever reason, it's not been included in Xalan (I'm using > Cocoon 2.1.11 which uses Xalan 2.7.1 by default). > > I've tried to download and use the date.seconds.xsl template and > included Javascript and MSXML XSL templates with a mixture of > and xmlns:date declarations, but nothing seems to get the > two working together. > > Has anyone ever manually-plugged an EXSLT function into Xalan? How did > you do it? > > Thanks, > -chris > > > - > To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org > For additional commands, e-mail: users-h...@cocoon.apache.org > - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org
Re: Adding EXSLT functions
On 27/02/14 21:47, Christopher Schultz wrote: Has anyone ever manually-plugged an EXSLT function into Xalan? No, I changed the processor to Saxon so I can use XSLT2. The date and time functions there are much better and more extensive, and there is no need for plugins. ///Peter -- Peter Flynn | Electronic Publishing Unit | IT Services | University College Cork | Phone +353 21 490 2609 | Email pfl...@ucc.ie | Web www.ucc.ie - To unsubscribe, e-mail: users-unsubscr...@cocoon.apache.org For additional commands, e-mail: users-h...@cocoon.apache.org