xsl-list
[Top] [All Lists]

Re: [xsl] calling Java non static methods from XSLT

2016-06-04 20:45:31
Dimitre/Michael,
Thanks for your responses.
So here are some details of what the process does..

We get data feeds from an external source and there are huge number of
nodes. Because we can not run XSLT on this big XML, we pass it through
a sax parser  to slice nodes and the Java handler calls an XSLT
transformation for each of these nodes.
The XSLT then does some trasformations and returns a datafile to the
Java Handler which then sends the data file to some other location for
consumption.

So this is full cycle of the MTA process (market-trend-analysis
process as we call it).

Now coming to the details of the XSLT code itself, it may not do too
many things, but as one of the things it does, which prompted my
question, the xslt should call a Java method
MarketTrendAnalyser.calculate($param), where the param is the value
the XSLT should pass to the Java method . Java method then runs some
routines and returns a value back.

Here, The XSLT instantiates the MTA Class and calls the MTA.Calculate method.

The MTAHandler XSLT is a compiled XSLT ..

So since in one process , The Java slices the nodes, and for each node
it calls the MTAHandler.xsl , which in turn instantiates the Java
object, shouldnt the MTAObject be created as many times as the XSLT is
called?

Dimitre, your suggestion makes me feel that an object can be passed
into the XSLT and then I can do object.method() within the XSLT.. is
that possible?

My questions are :
1. Compiling the XSLT is irrelevant to this issue of the Object
creation right? Just because we are precompiling the XSLTs doesnt mean
that the XSLT will create the object once and keep it for all the
transformations? Or is it true? My assumption was, the Java Objects
are created at run time so it does not matter if the XSLTs are
compiled or not..
2. If my assumption is wrong, then would like to know what the
Compiling of XSLT works.
3. is there any benefits of actually using a static method instead of
instance methods, within XSLT?

Any pointers would be highly appreciated.

Dr. Tapaal.




On Sat, Jun 4, 2016 at 5:31 PM, Dimitre Novatchev 
dnovatchev(_at_)gmail(_dot_)com
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> wrote:
I am not completely sure, but I believe the Java object can be created
only once and then passed as parameter to each of the trillion
transformations.

As long as the code of the method is reentrant (doesn't create and
depend on state), everything should be OK, even if the transformations
are invoked even from different threads.

On a multicore machine, such transformations could be invoked on each
of several cores, and in this case the number of created objects can
be just the number of the participating cores.


--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
To avoid situations in which you might make mistakes may be the
biggest mistake of all
------------------------------------
Quality means doing it right when no one is looking.
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play
-------------------------------------
To achieve the impossible dream, try going to sleep.
-------------------------------------
Facts do not cease to exist because they are ignored.
-------------------------------------
Typing monkeys will write all Shakespeare's works in 200yrs.Will they
write all patents, too? :)
-------------------------------------
Sanity is madness put to good use.
-------------------------------------
I finally figured out the only reason to be alive is to enjoy it.

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>