-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
9
-
None
DOMSource and StreamSource both provides setSystemId API for setting base ID for file reference. When using StreamSource as InputSource for Transformer, the base ID get resolved
FileOutputStream fos = new FileOutputStream("dom.out");
InputStream xmlStream = new FileInputStream("SystemIdImpIncl.xml");
TransformerFactory factory = TransformerFactory.newInstance();
Source xslSource = new StreamSource(new InputStreamReader(new FileInputStream("/test/SystemIdImpIncl.xsl")));
xslSource.setSystemId("file:///test");
Source xmlSource = new StreamSource(xmlStream);
factory.newTemplates(xslSource).newTransformer().
transform(xmlSource, new StreamResult(fos));
DOMSource doesn't work for this case, the file wasn't correctly parsed and it doesn't throw any error.
FileOutputStream fos = new FileOutputStream("dom.out");
InputStream xmlStream = new FileInputStream("SystemIdImpIncl.xml");
TransformerFactory factory = TransformerFactory.newInstance();
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node xslNode = docBuilder.parse(new InputSource("file:///test/SystemIdImpIncl.xsl"));
Source xslSource = new DOMSource(xslNode);
xslSource.setSystemId("file:///test");
Source xmlSource = new StreamSource(xmlStream);
factory.newTemplates(xslSource).newTransformer().
transform(xmlSource, new StreamResult(fos));
FileOutputStream fos = new FileOutputStream("dom.out");
InputStream xmlStream = new FileInputStream("SystemIdImpIncl.xml");
TransformerFactory factory = TransformerFactory.newInstance();
Source xslSource = new StreamSource(new InputStreamReader(new FileInputStream("/test/SystemIdImpIncl.xsl")));
xslSource.setSystemId("file:///test");
Source xmlSource = new StreamSource(xmlStream);
factory.newTemplates(xslSource).newTransformer().
transform(xmlSource, new StreamResult(fos));
DOMSource doesn't work for this case, the file wasn't correctly parsed and it doesn't throw any error.
FileOutputStream fos = new FileOutputStream("dom.out");
InputStream xmlStream = new FileInputStream("SystemIdImpIncl.xml");
TransformerFactory factory = TransformerFactory.newInstance();
DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Node xslNode = docBuilder.parse(new InputSource("file:///test/SystemIdImpIncl.xsl"));
Source xslSource = new DOMSource(xslNode);
xslSource.setSystemId("file:///test");
Source xmlSource = new StreamSource(xmlStream);
factory.newTemplates(xslSource).newTransformer().
transform(xmlSource, new StreamResult(fos));