Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 16th, 2013, 09:35 AM
Authorized User
 
Join Date: Nov 2012
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default Java extensions performance

Hi all,

I´m trying to make more efficient my xslt (it´s a very big one) and I´m wondering if my Java extension calls are being heavier than I thought.

I can´t avoid using them because I need bit operations with some xml elements.

Are there any good practices about Java extensions?

I mean: declaring few namespaces or as many as classes I have; or making few "heavy" calls instead of many light ones...

Thank you very much again.

Best regards!
 
Old May 16th, 2013, 10:02 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Well firstly, one can't answer any questions about performance without knowing what XSLT processor you are using.

Secondly, it's very likely that crossing a boundary between two programming languages will incur a substantial overhead, especially if the extension function itself is doing very little work (like flipping a few bits).

Thirdly, some processors may be less aggressive in the optimizations they attempt if there are calls to external functions, because they have no knowledge of what the external functions are doing.

You may find that implementing the bitwise operations in XSLT, even if it seems very inefficient, is faster than calling across the fence to Java.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
The Following User Says Thank You to mhkay For This Useful Post:
sportinguista (May 16th, 2013)
 
Old May 16th, 2013, 10:34 AM
Authorized User
 
Join Date: Nov 2012
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Thank you Michael.

I´m testing with Xalan (2.7) and Saxon (9.4).

My Java methods are called for operations like: testing Nth bit, switching pair of bits, decimal to hex, decimal to binary, hex to base64 conversions, etc.

So I have declared one namespace for each Java class and call them as:
xmlns:javaCoder="com.xxxxxxx.Coder".

I know I should start considering making bitwise operations in xsl, but searching in forums I see very large implementations that seem, as you said, very inefficient.

Finally, what xslt processor do you think is better for more efficient Java extensions callings?

Thank you again Michael. It´s always an honor to be answered by you.
 
Old May 16th, 2013, 10:57 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

It might be worth trying it in Saxon-EE with bytecode generation enabled. When bytecode is generated, the dynamic/reflexive call to the Java method becomes a static compiled call and this can potentially make a big difference.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old May 16th, 2013, 11:06 AM
Authorized User
 
Join Date: Nov 2012
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Wow, thank you very much Miachel. I´ll try that.

Regards!
 
Old May 22nd, 2013, 07:10 AM
Authorized User
 
Join Date: Nov 2012
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Excuse me again Michael:

1) I´m currently using xsl v 1.0. If I want to deal with bitwise operations: do you recomend using xsl version 2? (in terms of performance and available functions)

2) Is there any way of enconding from hexadecimal to base64 in xslt? Do you recomend using java extensions for that?

Thank you Michael, I´m very grateful to you.

Please, let me know if I should open a new thread for that.

Regards.
 
Old May 22nd, 2013, 07:24 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

XSLT 2.0 will double your productivity, so absolutely, use it if you can. Performance of course depends on the choice of processor not just on the XSLT version supported.

XSLT 2.0 supports some limited functionality for binary data encoded in hexBinary or base64Binary. Saxon (at least in Saxon-PE) has a rather wider range, though the functions don't include bit-twiddling. See

http://www.saxonica.com/documentation/#!functions/saxon
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Saxon Extensions from Java Applet WilliamYou XSLT 3 November 9th, 2012 11:32 AM
Extensions in Java and null pointers rushman XSLT 3 November 3rd, 2009 12:44 PM
Jumping into java extensions to Saxon mphare XSLT 2 April 29th, 2008 10:02 PM
entity handling with java extensions stolte XSLT 2 January 23rd, 2008 05:31 AM
Java Performance!! Ibn_Aziz JSP Basics 0 September 6th, 2003 08:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.