RE: [xsl] Difference between saxon transform.exe and net.sf.saxon.Transform

Subject: RE: [xsl] Difference between saxon transform.exe and net.sf.saxon.Transform
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 23 Mar 2010 09:40:12 -0000
A question that is so strongly Saxon-specific would be better asked on the
saxon-help list (via the project page on SourceForge).

By and large, Saxon's collation facilities offered on the Java platform are
based on facilities in the JDK libraries, whereas the facilities offered on
the .NET platform are based on the .NET collation infrastructure. However,
if you specify a class-based collation under .NET, Saxon will attempt to
load it and use it. (In this case, it is making the attempt and it is
failing). The problem is getting dynamic loading of Java classes to work in
the .NET environment. Jeroen Frijters has been gradually improving the IKVM
facilities in this area but it's still something of a black art, with many
restrictions and poor documentation.

In principle it should work the same way as writing dynamically-loaded
extension functions under .NET - see
http://www.saxonica.com/documentation/extensibility/dotnetextensions.html.
However, as that page describes, when loading extension functions Saxon
allows you to name the assembly or file from which they are to be loaded;
there's nothing similar for loading collation support classes.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Larry Hayashi [mailto:lhtrees@xxxxxxxxx] 
> Sent: 23 March 2010 02:26
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Difference between saxon transform.exe and 
> net.sf.saxon.Transform
> 
> I've spent some time trying to get a custom collation to work 
> on an indigenous language using Saxon. I eventually figured 
> out how to do it but am still a little perplexed. I have not 
> programmed in java before but was able to copy and adapt some 
> java code to create a class that extends the 
> RuleBasedCollator (refer to:
> http://www.ibm.com/developerworks/library/x-xsltsorting/ and
> http://java.sun.com/javase/6/docs/api/java/text/RuleBasedColla
> tor.html)
> 
> Could someone explain to me why this works:
> 
> java net.sf.saxon.Transform -o testout.xml "LIFTExport.xml"
> "LIFTCustomCollated.xsl"
> 
> but this does not:
> Transform.exe -s:"LIFTExport.xml" 
> -xsl:"LIFTCustomCollated.xsl" -o:testout.xml
> 
> with the following stylesheet (of particular interest the 
> xsl:sort collation):
> 
> <xsl:stylesheet version="2.0" 
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
>     <xsl:output method="xml"/>
>     <xsl:template match="/">
>         <xsl:apply-templates/>
>     </xsl:template>
> 
>     <xsl:template match="lift">
>         <lift>
>             <xsl:apply-templates mode="copy" select="@*"/>
>             <xsl:apply-templates select="header"/>
>             <xsl:apply-templates select="entry">
>                 <xsl:sort select="lexical-unit/form[@lang='tsi']/text"
> order="ascending"
> 
> collation="http://saxon.sf.net/collation?class=com.lhtrees.xsl
t.LangXCollation;"
>                 />
>             </xsl:apply-templates>
>         </lift>
>     </xsl:template>
>     <xsl:template match="header">
>         <header>
>             <xsl:apply-templates mode="copy"/>
>         </header>
>     </xsl:template>
> 
>     <xsl:template match="entry">
>         <entry>
>             <xsl:apply-templates mode="copy"/>
>         </entry>
>     </xsl:template>
>     <!-- Deep copy template -->
>     <xsl:template match="*|text()|@*" mode="copy">
>         <xsl:copy>
>             <xsl:apply-templates mode="copy" select="@*"/>
>             <xsl:apply-templates mode="copy"/>
>         </xsl:copy>
>     </xsl:template>
>     <!-- Handle default matching -->
>     <xsl:template match="*"/>
> </xsl:stylesheet>
> 
> I am using saxon9. When I use the Transform.exe command line 
> I get the following error:
> 
> Warning: Failed to load com.lhtrees.xslt.LangXCollation
> Warning: Failed to load com.lhtrees.xslt.LangXCollation Error 
> at xsl:sort on line 23 column 91 of liftCustomCollated.xsl:
>   XTDE1035: Collation
> http://saxon.sf.net/collation?class=com.lhtrees.xslt.LangXCollation;
>   has not been defined
> Failed to compile stylesheet. 1 error detected.
> 
> I'm glad it works with java net.sf.saxon.Transform but would 
> like to understand the difference.
> 
> Thank you for any enlightenment you can give.
> 
> Larry

Current Thread