I am storing xslt in database. I want to call the a template from another xslt that too is stored in database. Using below sample code I am able to run the xslt correctly (consider xsltOneStr is xslt string coming from database via dao layer so is xmlStr which is xml to be parsed)
However if I use in xsltOne.xsl, it will obviously complain since the source xsltOne.xsl is from db and the called xsltTwo.xsl too is in DB. Obviously it is logically incorrect to use import in my case since I am not using filesystem to get xsl but stream of characters coming from DB but for sake of conversation I used import tag.
So the question since xsl is coming from DB what should I use instead of xsl:import. I am using Java & xslt is able to call java method. Is there any way I can use java method to call second xslt that resides in db (xsltTwo.xsl). If xsltTwo.xsl in it entirety can cannot be called by java method can I at least insert a template declared in xsltTwo on the fly in xsltOne.xsl
For example we can call java method to assign value to xsl parameter using java as
Similarly can we assign the whole template or call one xslt from another xslt using java method?
Source xsltOne=new StreamSource(new StringReader(xsltOneStr));
Source xml =new StreamSource(new StringReader(xmlStr));
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(xsltOne);
StringWriter writer = new StringWriter();
transformer.transform(xml, new StreamResult(writer));