DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5363>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5363 Problem with setInclude() and a 'ghost' template [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|FIXED | ------- Additional Comments From [EMAIL PROTECTED] 2002-03-07 10:02 ------- The bug is still present, also in 2.3.1. But now there is also another problem with, I suppose, the following instruction: sheet1.setInclude(sheet2); that doesn't work as it should because with 2.3.1 the exception is: javax.xml.transform.TransformerException: Could not find template named: main instead with 2.2 is 'only': javax.xml.transform.TransformerException: Could not find template named: body You can test everything using this code: package testxalan; import javax.xml.transform.*; import javax.xml.transform.stream.*; import java.io.*; import org.apache.xalan.templates.*; public class test { protected static final String XML_EMPTY = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><root/>\n"; protected static final String XSL1 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + "<xsl:template match=\"/\">" + "<xsl:call-template name=\"main\"/>" + "</xsl:template>" + "<xsl:template name=\"body\">" + "Hello world!" + "</xsl:template>" + "</xsl:stylesheet>"; protected static final String XSL2 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\">" + "<xsl:template name=\"main\">" + "<html>" + "<body>" + "<xsl:call-template name=\"body\"/>" + "</body>" + "</html>" + "</xsl:template>" + "</xsl:stylesheet>"; public static void main(String[] args) { try { TransformerFactory tf = TransformerFactory.newInstance(); StreamSource xml = new StreamSource(new ByteArrayInputStream (XML_EMPTY.getBytes())); Source s1 = new StreamSource(new ByteArrayInputStream(XSL1.getBytes())); Source s2 = new StreamSource(new ByteArrayInputStream(XSL2.getBytes())); StylesheetRoot sheet1 = (StylesheetRoot)tf.newTemplates(s1); StylesheetRoot sheet2 = (StylesheetRoot)tf.newTemplates(s2); sheet1.setInclude(sheet2); sheet1.recompose(); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); Transformer tr = sheet1.newTransformer(); tr.transform(xml, result); System.out.println(result.toString()); } catch (java.lang.Throwable e) { System.out.println(e.toString()); } } }
