[xsl] Import stylesheets in Xalan again

Subject: [xsl] Import stylesheets in Xalan again
From: "Andrey Guskov" <andrey.guskov@xxxxxxx>
Date: Sun, 23 Feb 2003 10:01:53 +0300
Thank you for your answers but they don't solve the problem.
I want to give some explanations about my situation.
We have web application which pages have xml mark-up and the design created by xsl.
There are many xsl templates which are used by all pages in our project. So we want to put
them into the separate file and import this stylesheet in all other files.
In order to decrease the transformation time we want to parse this stylesheet on application
loading and store it in the memory so we are able to automatically import it during the 
concrete transformation. So standard <xsl:import> and <xsl:include> instruction is not applicable.

The following code work perfectly in Xalan-1:

//On application loading:
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
Vector imports = new Vector();
StylesheetRoot sheet1 = processor.processStylesheet(xslInputSource1);
imports.add(sheet1);
//During the concrete transformation:
StylesheetRoot sheet2 = processor.processStylesheet(xslInputSource2);
sheet2.setImports(imports); //special method for importing parsed stylesheets
//In this case sheet2 contains templates from both stylesheets sheet1 and sheet2

But the following code similar to the previous one doesn't work in Xalan-2:

//On application loading:
TransformerFactory factory = TransformerFactory.newInstance();
StylesheetRoot sheet1 = (StylesheetRoot)factory.newTemplates(xslInputSource1);
//During the concrete transformation:
StylesheetRoot sheet2 = (StylesheetRoot)factory.newTemplates(xslInputSource2);
sheet2.setImport(sheet1);
//In this case sheet2 still contains templates only from stylesheets sheet2;
//templates from sheet1 are not found during the xml transformation

I'll be very thankful if you help me to solve this problem.
Andrey

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread