You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2001/04/23 08:40:36 UTC

[Bug 1455] New - Problem with newTemplates(new DOMSource(xsldocument))

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=1455

*** shadow/1455	Sun Apr 22 23:40:36 2001
--- shadow/1455.tmp.2082	Sun Apr 22 23:40:36 2001
***************
*** 0 ****
--- 1,56 ----
+ +============================================================================+
+ | Problem with newTemplates(new DOMSource(xsldocument))                      |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 1455                        Product: XalanJ2                 |
+ |       Status: NEW                         Version: 2.0.1                   |
+ |   Resolution:                            Platform: PC                      |
+ |     Severity: Major                    OS/Version: Windows NT/2K           |
+ |     Priority: High                      Component: javax.xml               |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: xalan-dev@xml.apache.org                                     |
+ |  Reported By: thomas2.maesing@bgs-ag.de                                    |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Hi,
+ creating a Templates from a DOMSource does not work.
+ 
+ This is the code before this method:
+ 
+     public SaveTemplates(String doctype) throws SaveTemplatesException {
+         try {
+            processor = TransformerFactory.newInstance();
+             ByteArrayOutputStream xslbyteresult = new ByteArrayOutputStream();
+             StreamResult xslbufferResult = new StreamResult(xslbyteresult);
+             DomFactory = DocumentBuilderFactory.newInstance();
+             DocumentBuilder DomBuilder = DomFactory.newDocumentBuilder();
+             Document xsldocument = DomBuilder.parse(
+                 new InputSource(xsltSource));
+             Element output = (Element)xsldocument.getElementsByTagName
+ ("xsl:output").item(0);
+             if (output.hasAttribute("doctype-system")) {
+                 output.removeAttribute("doctype-system");
+                 output.setAttribute("doctype-system", doctype);
+             }
+             else {
+                 output.setAttribute("doctype-system", doctype);
+             }
+             DOMSource xslSource = new DOMSource(xsldocument);
+ 
+ The following workaround works fine:
+ 
+             Transformer xslserializer = processor.newTransformer();
+             xslserializer.transform(xslSource, xslbufferResult);
+             byte[] xslbuffer = xslbyteresult.toByteArray();
+             save = processor.newTemplates(
+                 new StreamSource(
+                 new ByteArrayInputStream(xslbuffer)));
+ 
+ So I think it is a problem of Xalan. In my opinion the different Sources 
+ including DOM Nodes are an important feature of JAXP.
+ 
+ Regards
+ 
+ Thomas