You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Loïc Trégan <lt...@hotmail.com> on 2000/10/18 06:51:24 UTC
processing does not work with Node
Hi all,
I can not explain the output produced by the above code; is it a bug ? My
current workaround is to stream my Node then use the file as input; anything
better ?
Once fixed, it would be easier if both (1) and (2) can be used : in some
cases I want to process only a branch of my Document.
Thanks for your help.
PS : please send me personnaly a copy of your potential answer(s).
static public void TestXalanBUGGYDOM2() throws Exception {
// create simple XSL
String SIMPLE_XSL =
"<xsl:stylesheet xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"
version=\"1.0\">"
+"<xsl:template match=\"/\">"
+" This is XSL <xsl:apply-templates select=\"*\" /> "
+"</xsl:template>"
+"</xsl:stylesheet>";
// create simple DOM
XMLParserLiaison parserLiaison = new
org.apache.xalan.xpath.xdom.XercesLiaison();
Document doc = parserLiaison.createDocument();
Node root = doc.createElement( "root" );
Node text = doc.createTextNode( "This is XML");
root.appendChild( text );
// set sources
// XSLTInputSource xmlID = new XSLTInputSource( root ); // (1)error:
output="This is XML"
// XSLTInputSource xmlID = new XSLTInputSource( doc ); // (2)error:
output="This is XSL"
XSLTInputSource xmlID = new XSLTInputSource( "file:c:/temp/root.xml" );
// (3)correct : output="This is XSL This XML"
XSLTInputSource stylesheetID = new XSLTInputSource( new
StringReader(SIMPLE_XSL) );
XSLTResultTarget resultTarget = new XSLTResultTarget(System.out);
// display
XSLTProcessor processor =
XSLTProcessorFactory.getProcessor(parserLiaison);
processor.process(xmlID, stylesheetID, resultTarget);
}