[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Call java function to do background work

Subject: Re: Call java function to do background work
From: Ming Yu <my600080@xxxxxxxxx>
Date: Tue, 19 Jun 2012 08:17:33 -0700 (PDT)
Re:  Call java function to do background work
Thanks a lot! I am actually using xsl:result-document when I need to generate
multiple output files from one source file. But I'm not using it when it's
one-to-one scenario. The variable I'm appending to from my background function
call is for sure being used. In this case, I can make sure that the background
function call will be executed.

Again, thanks for the help.

Ming


-----
Original Message -----
From: Michael Kay <mike@xxxxxxxxxxxx>
To:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: 
Sent: Tuesday, June 12, 2012 1:10 PM
Subject: Re:  Call java function to do background work


It's not a good
idea to do something involving side-effects while evaluating a variable,
because optimizers tend to assume that evaluating a variable is something they
can do as and when and as often as they please. If the variable isn't used,
it's very likely that it will never be evaluated; if two variables are
involved, it's unpredictable which order they will be evaluated in. In some
cases an optimizer might decide to evaluate a variable repeatedly rather than
allocating memory to hold its value.

It might not seem an obvious approach,
but my suggestion would be to do this using xsl:result-document. That's about
the closest XSLT gets to an instruction designed to have side effects, and
there are rules about its behaviour designed to limit the damage that
optimizers can do. There's still no absolute rule ensuring the order in which
different result documents are generated (in recent Saxon releases, you can
create lots of result documents in parallel), but at least there's a
reasonable chance that each one will be written exactly once.

In Saxon
there's a mechanism (the OutputURIResolver) that allows the Java application
to intercept calls to xsl:result-document. So by encapsulating the information
needed by the application within the URI given to the result document (or
putting it within the document itself) you can use xsl:result-document as a
way of saying "here's some information, please process it in the background".
Michael Kay
Saxonica

On 12/06/2012 16:07, Ming Yu wrote:
> Sorry if this is a
very simple question but I couldn't seem to come up with a neat solution.
> 
>
During xslt transformation, I need to call a java function to do some
background work (such as adding some values to the database, etc). The java
function doesn't need to return anything. At this moment, I just use the
normail<xsl:value-of>  tag to append to a variable. Since it doesn't return
anything, the variable value stays the same.
> 
> Is there a neater to achieve
this goal?
> 
> Thanks a lot!
> 
> Ming
> 
>
--~------------------------------------------------------------------
>
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@xxxxxxxxxxxxxxxxxxxxxx>
> --~--

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.