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 February 2nd, 2009, 04:28 PM
Authorized User
 
Join Date: Apr 2008
Posts: 70
Thanks: 17
Thanked 1 Time in 1 Post
Send a message via Yahoo to iceandrews
Default Faster Performance

I have question regarding which stylesheet will be the faster performing one.

The input document is a XML document with thousands of lines.

The transformation that I'm running contains a lookup table in the following format:

Code:
<xsl:variable name="lobNamespaces">
     <LOBTable>
         <LOBs>
             <LOB LOBCode="URI1">
                 <Namespace>http://uri1.com</Namespace>
                 <NamespacePrefix>uri1</NamespacePrefix>
                 <Description>text1</Description>
             </LOB>
             <LOB LOBCode="URI2">
                 <Namespace>http://uri2.com</Namespace>
                 <NamespacePrefix>uri2</NamespacePrefix>
                 <Description>text2</Description>
             </LOB>
     ....
     ....
     (more LOBS)
         </LOBs>
     </LOBTable>
</xsl:variable>
This is a recursive transformation that looks at each element node in the incoming document. Some of the nodes contain an attribute @NSTag. The transformation finds this NSTag and then applies a certain template based on the value of that NSTag attribute. I have 2 ways of doing it, one with explicit pathing on the lookup table and one using a key structure. Obviously this is only a fraction of the code, but i think it provide the right idea. We are running in a saxon enviroment on a service bus. Which one would be the faster implementaion performance wise? I have a feeling the key valued transformation is the better perfomer.

Transformation Template 1 (Explicit Pathing)
Code:
...
<xsl:apply-templates select=".">
     <xsl:with-param name="PF" select="$lobNamespaces/LOBTable/LOBs/LOB[@LOBCode = current()/@NSTag]/NamespacePrefix"/>
     <xsl:with-param name="NS" select="$lobNamespaces/LOBTable/LOBs/LOB[@LOBCode = current()/@NSTag]/Namespace"/>
</xsl:apply-templates>
Transformation Template 2 (Keyed Values)
Code:
<xsl:key name="LOBKey" match="LOBTable/*/LOB" use="@LOBCode"/> 
...
...
<xsl:apply-templates select=".">
     <xsl:with-param name="PF" select="$lobNamespaces/key('LOBKey', current()/@NSTag)/NamespacePrefix"/>
     <xsl:with-param name="NS" select="$lobNamespaces/key('LOBKey', current()/@NSTag)/Namespace"/>
</xsl:apply-templates>
Thank you and I appreciate your insights!
 
Old February 2nd, 2009, 05:09 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Using the key is likely to be faster on most processors. However, a processor with a strong optimizer like Saxon-SA will do just as well with either. Really, all performance questions depend on the product you are using and the best way to get an answer is to measure it.
__________________
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:
iceandrews (February 2nd, 2009)
 
Old February 2nd, 2009, 05:17 PM
Authorized User
 
Join Date: Apr 2008
Posts: 70
Thanks: 17
Thanked 1 Time in 1 Post
Send a message via Yahoo to iceandrews
Default

Quote:
Originally Posted by mhkay View Post
Using the key is likely to be faster on most processors. However, a processor with a strong optimizer like Saxon-SA will do just as well with either. Really, all performance questions depend on the product you are using and the best way to get an answer is to measure it.
Thank you very much! Unfortunately we don't have the luxury to performance test it as much as we would like. We are, however, using the Saxon-SA ver 9 so it should be pretty fast! We've been really pleased with the product.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Faster Performance iceandrews BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition ISBN: 978-0-470-19274-0 1 February 2nd, 2009 05:06 PM
which is faster pegasus51 Ajax 3 December 30th, 2007 08:56 AM
They Want It To Be Faster! kindler Access 7 December 20th, 2005 10:54 AM
c++ faster than Pascal IvAnR C++ Programming 5 August 6th, 2005 12:08 AM
Any faster? Ben Access VBA 19 March 12th, 2004 07:04 PM





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