Gentlemen,

I have a web application that uses, on the browser-side, XSL transforms.
Alas, because of a little issue in WebKit (affecting Google Chrome,
Safari, ...), I cannot use composed XSLTs (i.e., XSLs that
<xsl:include>s other bits of XSL) in Chrome.

I thought I'd give xalan-java a try at solving my problem, by
"composing" the XSLT bits into one big XSL, on the server-side. 
That composed XSL could then be used by all browsers.

Here's what I had in mind: 
 * get xalan-java to load the XSL.
 * get xalan-java to load its children.
 * dump the composed XSL as String, or byte [].

And here's my first attempt at this task:


            TransformerFactory tFactory = TransformerFactory.newInstance();
            Transformer transformer = tFactory.newTransformer
                (new StreamSource("/path/to/xslt/common.xslt"));

            TransformerImpl transformerImpl = (TransformerImpl) transformer;
            StylesheetRoot stylesheetRoot = transformerImpl.getStylesheet();
            stylesheetRoot.recompose();
            Document stylesheetDoc = stylesheetRoot.getOwnerDocument();
            W3CNodeHelper nodeHelper = new W3CNodeHelper(); 
            String out = 
nodeHelper.dumpAsString(stylesheetDoc.getChildNodes().item(0));



(Where the "W3CNodeHelper" thingy is just one of our tools I use to dump
the document.)

Unfortunately this fails, as:
java.lang.RuntimeException: ElemTemplateElement error: Function not
supported!
        at
org.apache.xalan.templates.ElemTemplateElement.error(ElemTemplateElement.java:223)
        at
org.apache.xalan.templates.ElemTemplateElement.error(ElemTemplateElement.java:236)
        at org.apache.xml.utils.UnImplNode.getAttributes(UnImplNode.java:641)
        at
com.ionicsoft.xml.dom.W3CNodeHelper.dumpElement(W3CNodeHelper.java:992)
        at com.ionicsoft.xml.dom.W3CNodeHelper.dump(W3CNodeHelper.java:851)
        at com.ionicsoft.xml.dom.W3CNodeHelper.dump(W3CNodeHelper.java:825)
        at
com.ionicsoft.xml.dom.W3CNodeHelper.dumpAsString(W3CNodeHelper.java:802)
        at com.Test.main(Test.java:43)


I guess this method is far from ideal. Would anyone have any information
on how I could achieve what I'm trying to?

Thanks a bunch for any info/pointer!

Regards,
        A.



Reply via email to