Problem with Java external function call in Saxon 9.2 HE

View: New views
6 Messages — Rating Filter:   Alert me  

Problem with Java external function call in Saxon 9.2 HE

by Toshihiko Makita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear List,

I have made a Java external function and it works fine with Saxon-B
9.1.0.8. The code fragment are follows:

<xsl:stylesheet version="2.0"
     xmlns:db="http://docbook.org/ns/docbook"
     xmlns:fo="http://www.w3.org/1999/XSL/Format"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:i18n_index_saxon9="java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9"
     extension-element-prefixes="i18n_index_saxon9"
     exclude-result-prefixes="i18n_index_saxon9">
...
<xsl:variable name="indextermSorted">
     <xsl:message>XSLT processor=<xsl:value-of
select="system-property('xsl:product-name')"/> version=<xsl:value-of
select="system-property('xsl:product-version')"/></xsl:message>
     <xsl:message>Function i18n_index_saxon9:indexSortSaxon9
availability=<xsl:value-of
select="function-available('i18n_index_saxon9:indexSortSaxon9')"/></xsl:message>
     <xsl:copy-of select="i18n_index_saxon9:indexSortSaxon9($glSetLang,
$indextermOrigin, string($glAssumeSortasPinyin))"/>
</xsl:variable>

Saxon-B9.1.0.8 displays following message.

XSLT processor=SAXON version=9.1.0.8
Function i18n_index_saxon9:indexSortSaxon9 availability=true

But when I switched XSLT processor to Saxon 9.2.0.3, Saxon reports
stylesheet compile error as follows:

Error at xsl:copy-of on line 65 column 120 of dbtofo2_index.xsl:
   XPST0017: XPath syntax error at char 94 on line 65 in
{...string($glAssumeSort
asPinyi...}:
     Cannot find a matching 3-argument function named
   {java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9}indexSortSaxon9()
Failed to compile stylesheet. 1 error detected.

Are there any specification change in Saxon 9.2? I want to know how to
solve this problem.

Regards,

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail tmakita@...
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Problem with Java external function call in Saxon 9.2 HE

by Toshihiko Makita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

In addition, the Java external function is defined in the class
jp.co.antenna.ah_i18n_index.IndexSortSaxon9 as follows:

public static org.w3c.dom.NodeList indexSortSaxon9(String lang,
org.w3c.dom.Node indextermInfo, String assumeSortasPinyin)

On 11/11/2009 11:26 AM, Toshihiko Makita wrote:

> Dear List,
>
> I have made a Java external function and it works fine with Saxon-B
> 9.1.0.8. The code fragment are follows:
>
> <xsl:stylesheet version="2.0"
>      xmlns:db="http://docbook.org/ns/docbook"
>      xmlns:fo="http://www.w3.org/1999/XSL/Format"
>      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> xmlns:i18n_index_saxon9="java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9"
>      extension-element-prefixes="i18n_index_saxon9"
>      exclude-result-prefixes="i18n_index_saxon9">
> ...
> <xsl:variable name="indextermSorted">
>      <xsl:message>XSLT processor=<xsl:value-of
> select="system-property('xsl:product-name')"/> version=<xsl:value-of
> select="system-property('xsl:product-version')"/></xsl:message>
>      <xsl:message>Function i18n_index_saxon9:indexSortSaxon9
> availability=<xsl:value-of
> select="function-available('i18n_index_saxon9:indexSortSaxon9')"/></xsl:message>
>      <xsl:copy-of select="i18n_index_saxon9:indexSortSaxon9($glSetLang,
> $indextermOrigin, string($glAssumeSortasPinyin))"/>
> </xsl:variable>
>
> Saxon-B9.1.0.8 displays following message.
>
> XSLT processor=SAXON version=9.1.0.8
> Function i18n_index_saxon9:indexSortSaxon9 availability=true
>
> But when I switched XSLT processor to Saxon 9.2.0.3, Saxon reports
> stylesheet compile error as follows:
>
> Error at xsl:copy-of on line 65 column 120 of dbtofo2_index.xsl:
>    XPST0017: XPath syntax error at char 94 on line 65 in
> {...string($glAssumeSort
> asPinyi...}:
>      Cannot find a matching 3-argument function named
>    {java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9}indexSortSaxon9()
> Failed to compile stylesheet. 1 error detected.
>
> Are there any specification change in Saxon 9.2? I want to know how to
> solve this problem.
>
> Regards,
>

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail tmakita@...
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Problem with Java external function call in Saxon 9.2 HE

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>      Cannot find a matching 3-argument function named
>    {java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9}indexSortSaxon9()
> Failed to compile stylesheet. 1 error detected.
>
> Are there any specification change in Saxon 9.2? I want to
> know how to solve this problem.
>

Yes, the packaging of functionality across Saxon editions has changed in
Saxon 9.2. Dynamic calling of extension functions using Java reflection is
now available only in Saxon-PE and Saxon-EE.

Your choices are:

* stay with Saxon-B 9.1

* upgrade to Saxon-PE or Saxon-EE

* re-implement the extension function using the new mechanism of "integrated
extension functions", as described at
http://www.saxonica.com/documentation/extensibility/integratedfunctions.html

I'm sorry if none of these options is immediately appealing: it was a
commercial decision.

Regards,

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


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Problem with Java external function call in Saxon 9.2 HE

by Toshihiko Makita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Michael,

Thank you for your reply.

 > Your choices are:
 >
 > * stay with Saxon-B 9.1
 >
 > * upgrade to Saxon-PE or Saxon-EE
 >
 > * re-implement the extension function using the new mechanism of
 > "integrated extension functions", as described at
 >
http://www.saxonica.com/documentation/extensibility/integratedfunctions.html

I want upgrade to Saxon-PE.
By the way Saxon-PE & EE seems to support both traditional way
(reflexive extension functions) and "integrated extension functions".
Should I re-implement my extension function using "integrated extension
functions"? Please give me your opinion.

Regards,


On 11/11/2009 5:50 PM, Michael Kay wrote:

>>      Cannot find a matching 3-argument function named
>>    {java:jp.co.antenna.ah_i18n_index.IndexSortSaxon9}indexSortSaxon9()
>> Failed to compile stylesheet. 1 error detected.
>>
>> Are there any specification change in Saxon 9.2? I want to
>> know how to solve this problem.
>>
>
> Yes, the packaging of functionality across Saxon editions has changed in
> Saxon 9.2. Dynamic calling of extension functions using Java reflection is
> now available only in Saxon-PE and Saxon-EE.
>
> Your choices are:
>
> * stay with Saxon-B 9.1
>
> * upgrade to Saxon-PE or Saxon-EE
>
> * re-implement the extension function using the new mechanism of "integrated
> extension functions", as described at
> http://www.saxonica.com/documentation/extensibility/integratedfunctions.html
>
> I'm sorry if none of these options is immediately appealing: it was a
> commercial decision.
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay 
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail tmakita@...
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Problem with Java external function call in Saxon 9.2 HE

by Michael Kay :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> Should I re-implement my extension function using "integrated
> extension functions"? Please give me your opinion.

The main advantages of doing so are:

(a) Saxon has a lot more information about the function at compile time,
enabling it to do a better job of type checking and optimization

(b) The implementation of the function itself can do things at compile time,
like making access to the static context, and pre-evaluation of arguments
(e.g. pre-compilation of a regular expression if supplied as a
string-literal)

(c) There's no unpredictability or run-time overhead associated with
conversion of arguments and result values between Java classes and XPath
types

(d) It's more secure: you can allow untrusted stylesheets/queries to use
integrated extension functions, whereas it would be unsafe to allow them to
call reflexive extension functions.

(e) They're available on all Saxon editions from Saxon 9.2 onwards.

The main disadvantages are:

(a) integrated extension functions need to be registered with the
Configuration, which makes things a bit awkward when running from the
command line

(b) there is less portability to other Java XSLT processors such as Xalan

(c) there's more code to write (and in particular, you can't simply call
existing Java methods without any Saxon-specific wrapper code).

Hope this helps!

Regards,

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


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help 

Re: Problem with Java external function call in Saxon 9.2 HE

by Toshihiko Makita :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Dear Michael,

Thank you for your detailed explanation.

 > (b) there is less portability to other Java XSLT processors
 > such as Xalan
As I'm writing XSLT 2.0 stylesheets, there is no problem. I will
re-consider what to do.

Best regards,


On 11/11/2009 6:29 PM, Michael Kay wrote:

>> Should I re-implement my extension function using "integrated
>> extension functions"? Please give me your opinion.
>
> The main advantages of doing so are:
>
> (a) Saxon has a lot more information about the function at compile time,
> enabling it to do a better job of type checking and optimization
>
> (b) The implementation of the function itself can do things at compile time,
> like making access to the static context, and pre-evaluation of arguments
> (e.g. pre-compilation of a regular expression if supplied as a
> string-literal)
>
> (c) There's no unpredictability or run-time overhead associated with
> conversion of arguments and result values between Java classes and XPath
> types
>
> (d) It's more secure: you can allow untrusted stylesheets/queries to use
> integrated extension functions, whereas it would be unsafe to allow them to
> call reflexive extension functions.
>
> (e) They're available on all Saxon editions from Saxon 9.2 onwards.
>
> The main disadvantages are:
>
> (a) integrated extension functions need to be registered with the
> Configuration, which makes things a bit awkward when running from the
> command line
>
> (b) there is less portability to other Java XSLT processors such as Xalan
>
> (c) there's more code to write (and in particular, you can't simply call
> existing Java methods without any Saxon-specific wrapper code).
>
> Hope this helps!
>
> Regards,
>
> Michael Kay
> http://www.saxonica.com/
> http://twitter.com/michaelhkay 
>
>
> ------------------------------------------------------------------------------
> Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
> trial. Simplify your report design, integration and deployment - and focus on
> what you do best, core application coding. Discover what's new with
> Crystal Reports now.  http://p.sf.net/sfu/bobj-july
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@...
> https://lists.sourceforge.net/lists/listinfo/saxon-help 
>

--
/*--------------------------------------------------
  Toshihiko Makita
  Development Group. Antenna House, Inc. Ina Branch
  E-Mail tmakita@...
  8077-1 Horikita Minamiminowa Vil. Kamiina Co.
  Nagano Pref. 399-4511 Japan
  Tel +81-265-76-9300 Fax +81-265-78-1668
  Web site:
  http://www.antenna.co.jp/
  http://www.antennahouse.com/
  --------------------------------------------------*/

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@...
https://lists.sourceforge.net/lists/listinfo/saxon-help