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 June 14th, 2007, 01:37 PM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default Performance and regular expressions

A general question about performance issues with XSLT. If I have two input documents and I am trying to match nodes using regular expressions, would I achieve better performance making a call to Java? I know this is quite vague, I am just curious if there is a known heavy cost for evaluating and using regexs in XSLT (Saxon8).

 
Old June 14th, 2007, 04:34 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Saxon uses the underlying regex engine in Java so I wouldn't expect it to make much difference. There is an overhead, because the XPath regex dialect isn't quite the same as the Java dialect and some constructs have to be translated, but that's usually a one-off cost at compile time. There is also an overhead in making calls from XSLT to Java, which can sometimes exceed the cost of actually doing the work.

As always with performance questions, the only way to find out is to measure it. Do remember that to get repeatable results from Java performance measurements you need to run the VM for at least a minute.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old June 15th, 2007, 09:29 AM
Authorized User
 
Join Date: Jun 2007
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there a way to keep hold of previously compiled regular expressions, it seems that you always need to recompile them. Using java, we compile once only and then work with the compiled objects.


 
Old June 15th, 2007, 09:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

You just have to trust the optimizer on this. With Saxon, provided the regular expression is written as a string literal in a place where a regex is expected, it will be compiled once at compile time.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with Regular Expressions WestRowOps Other Programming Languages 1 May 18th, 2007 05:34 AM
Regular Expressions mega Beginning PHP 1 February 5th, 2007 05:31 PM
Regular expressions on C# hideway C# 2 November 27th, 2006 05:08 PM
regular expressions help kyootepuffy Classic ASP Databases 2 September 10th, 2003 01:37 PM
Regular Expressions Dave Doknjas C# 1 August 9th, 2003 12:05 AM





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