Hello everyone,
i want to open a stream of xml, maybe a file and also
use an .xsl file for transforming it.
i Have so far :
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
File xmlFile = new File("item.xml");
File xsltFile = new File("item.xsl");
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, new StreamResult(out));
out.close();
}
but i will not show anything in the page,
IEplorer returns this error when is called
"XML document must have a top level element. Error processing resource '
By themselfs, the xml is displayed just fine using xsl
Also, is there a default location where .xml,.xsl files sohuld be ? The servlet doing the processing is in a package folder "newportal" within "WEB-INF classes".
thanx
i want to open a stream of xml, maybe a file and also
use an .xsl file for transforming it.
i Have so far :
response.setContentType("text/xml");
PrintWriter out = response.getWriter();
File xmlFile = new File("item.xml");
File xsltFile = new File("item.xsl");
Source xmlSource = new StreamSource(xmlFile);
Source xsltSource = new StreamSource(xsltFile);
TransformerFactory transFact =
TransformerFactory.newInstance();
Transformer trans = transFact.newTransformer(xsltSource);
trans.transform(xmlSource, new StreamResult(out));
out.close();
}
but i will not show anything in the page,
IEplorer returns this error when is called
"XML document must have a top level element. Error processing resource '
By themselfs, the xml is displayed just fine using xsl
Also, is there a default location where .xml,.xsl files sohuld be ? The servlet doing the processing is in a package folder "newportal" within "WEB-INF classes".
thanx