Using Multiple XSLT transformations.

Author: None (None)

I'm currently doing a lot of work with XSL, using the command: Activate "Usysxslt".Xmltransform (...) I have developed a group of generic xslt files to allow me to perform common task, such as renaming elements, changing the format of dates or removing empty elements. Usually I perform multiple calls to Usysxslt component, with of the output of the first call being used as the input for the second, and so on. However this is not as quick as I would like. I expect this is because it is having open and close the Java Xalan XSLT processor multiple times. Does any one know I can avoid this problem? Ideally I would like to instantiate the Xalan XSLT processor once, and then it perform each of the XSLT steps on the same xml file. I've written a COM interface to the Microsoft MSXML engine, which we could use instead but this would require additional software to be installed on each client, which I would like to avoid if possible. I realise I probably could re-write my xslt files into one master file that did all the transformations, but I would prefer not to have to do that as it?s simpler having the smaller generic files. I am currently using Uniface 9.

4 Comments

  1. Hi Jerry, Have a look at xsl:document, xsl:include, xsl:import and see if you can achieve your goal through these. Jason.


    Author: Jason Huggins (jason.huggins@uniface.com)
  2. Hi, do you have tried to use a central service with an componentvariable to keep the instance? e.g. myService operation XY params endparams if ($XSLT$ == "") newinstance "Usysxslt", $XSLT$ endif $XSTL$->TRANSFORM(....) return (0) end ; XY where $XSLT$ is a public handle variable, so you keep both in memory (your service and the xslt-instance). I haven't tried these but maybe it can avoid to open the xalan several times. HTH THOMAS


    Author: Thomas.Young (thomas.young@young-consulting.de)
  3. Thanks - I'll give this a go.


    Author: None (None)
  4. In principle this will work fine for regular components however, USYSXSLT is a stateless object so, it is not possible to create a persistent instance. Jerry, have you quantified the actual performance of starting the transform vs. processing the xsl templates? I just did a quick test with a simple style sheet and the execution time was generally less than 0.005s.


    Author: Jason Huggins (jason.huggins@uniface.com)