xsl-list
[Top] [All Lists]

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

2010-03-23 04:40:34

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(_at_)gmail(_dot_)com] 
Sent: 23 March 2010 02:26
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
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[(_at_)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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>