mmidy 99/12/14 07:08:19
Modified: samples/pipe foo.xsl foo2.xsl transform.java Log: Update Pipe test Revision Changes Path 1.2 +1 -1 xml-xalan/samples/pipe/foo.xsl Index: foo.xsl =================================================================== RCS file: /home/cvs/xml-xalan/samples/pipe/foo.xsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- foo.xsl 1999/11/08 20:55:09 1.1 +++ foo.xsl 1999/12/14 15:08:18 1.2 @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="doc"> <out><xsl:value-of select="."/></out> </xsl:template> 1.2 +1 -1 xml-xalan/samples/pipe/foo2.xsl Index: foo2.xsl =================================================================== RCS file: /home/cvs/xml-xalan/samples/pipe/foo2.xsl,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- foo2.xsl 1999/11/08 20:55:10 1.1 +++ foo2.xsl 1999/12/14 15:08:18 1.2 @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> +<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="out"> <out><xsl:value-of select="."/> ...and goodby!</out> </xsl:template> 1.3 +38 -7 xml-xalan/samples/pipe/transform.java Index: transform.java =================================================================== RCS file: /home/cvs/xml-xalan/samples/pipe/transform.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- transform.java 1999/11/09 14:55:40 1.2 +++ transform.java 1999/12/14 15:08:18 1.3 @@ -59,6 +59,13 @@ import org.apache.xalan.xslt.XSLTInputSource; import org.apache.xalan.xslt.XSLTResultTarget; import org.apache.xalan.xslt.XSLTProcessorFactory; +import org.apache.xalan.xslt.StylesheetRoot; +import org.apache.xalan.xslt.StylesheetHandler; +import org.apache.xalan.xslt.XSLTEngineImpl; +import org.apache.xalan.xslt.Constants; +import org.apache.xalan.xpath.xml.XMLParserLiaison; +import org.apache.xalan.xpath.xml.XSLMessages; +import org.apache.xalan.xslt.res.XSLTErrorResources; import org.apache.xerces.parsers.SAXParser; @@ -67,7 +74,10 @@ import java.io.BufferedReader; import java.io.FileReader; import java.io.Reader; +import java.io.FileOutputStream; +import java.lang.reflect.Constructor; import org.w3c.dom.Document; +import org.w3c.dom.Node; import org.xml.sax.InputSource; import org.xml.sax.SAXException; @@ -82,16 +92,37 @@ java.net.MalformedURLException, org.xml.sax.SAXException { - XSLTProcessor processor = XSLTProcessorFactory.getProcessor("foo.xsl"); - XSLTProcessor processor2 = XSLTProcessorFactory.getProcessor("foo2.xsl"); - - SAXParser parser = new SAXParser(); + String parserLiaisonClassName = Constants.LIAISON_CLASS; + XMLParserLiaison xmlProcessorLiaison; + + try + { + Class parserLiaisonClass = Class.forName(parserLiaisonClassName); + Constructor parserLiaisonCtor = parserLiaisonClass.getConstructor(null); + xmlProcessorLiaison + = (XMLParserLiaison)parserLiaisonCtor.newInstance(null); + } + catch(Exception e) + { + System.err.println(XSLMessages.createMessage(XSLTErrorResources.ERROR0025, new Object[] {parserLiaisonClassName})); //"Could not create XML Processor Liaison: "+parserLiaisonClassName); + return; + } + + XSLTProcessor processor = XSLTProcessorFactory.getProcessor(xmlProcessorLiaison); + StylesheetRoot stylesheet = processor.processStylesheet("foo.xsl"); + XSLTProcessor processor2 = XSLTProcessorFactory.getProcessor(xmlProcessorLiaison); + StylesheetRoot stylesheet2 = processor.processStylesheet("foo2.xsl"); - parser.setDocumentHandler(processor); - processor.setDocumentHandler(processor2); + FileOutputStream outputStream = null; + + outputStream = new FileOutputStream("foo.out"); + + processor.setDocumentHandler(new StylesheetHandler((XSLTEngineImpl)processor2,stylesheet2)); processor2.setOutputStream(System.out); + - parser.parse(new InputSource("foo.xml")); + Node sourceTree = processor.getSourceTreeFromInput(new XSLTInputSource("foo.xml")); + stylesheet.process(processor, sourceTree, new XSLTResultTarget(outputStream)); } }
