Subject: Attn Mike Kay (was using dom.Document as SAXON source) From: Warren Hedley <w.hedley@xxxxxxxxxxxxxx> Date: Tue, 21 Dec 1999 17:29:07 +1300 |
Kay Michael wrote: > > > Is it possible to apply SAXON to DOM documents using the public > > API? I had a look through the Stylesheet and Controller source, > > and it looks like SAXON builds something resembling a DOM before > > applying templates, but it uses a class (DocumentImpl) which > > doesn't explicitly implement any org.w3c.dom interfaces. > > No, this is not currently possible... <snip /> Thanks, fair enough. I'm now looking at not using DOM and XQL, but your DocumentInfo class and XPath expressions for querying. This should mean that I can perform queries and then transform without having to go through the DOM->SAX->DocumentInfo transformations. I haven't had much of a chance to try it yet, but on paper it looks good. The other problem I've encountered is with XMLEmitter, which calls close() on the Writer it is using inside the endDocument() method. I'm not sure if this is a good idea, mainly because that class is not responsible for calling open() (or init()) in the first place. It also prevents people from outputting more data using that writer. This is important to me, because I've been working (for about a year now) on an XML/XSL/XQL server (there's an old version which uses the DataChannel parser available at http://www.esc.auckland.ac.nz/People/Staff/Hedley/dcxjpServer/index.html ). I use a PrintWriter wrapped around a socket's output stream to pass XML data to my CGI scripts, and this data may include multiple query and XSLT results. This problem even prevents me (I think) from outputting two XSLT results to System.out. Feel free to tell me what's wrong with the following code, which stops outputting anything to standard out, after the first source document has been rendered. Any ideas? === BEGIN CODE import java.io.*; import com.icl.saxon.*; import com.icl.saxon.output.*; import org.w3c.dom.*; import org.xml.sax.*; public class SaxonTest { public static void main(String argv[]) throws Exception { String xmlData = "<?xml version=\"1.0\"?>\n<!DOCTYPE data>\n<data>\n" + "<element>text 1</element>\n<element>text 2</element>\n</data>\n"; String xslData = "<?xml version=\"1.0\"?>\n" + "<xsl:stylesheet xmlns:xsl = \"http://www.w3.org/1999/XSL/Transform\" " + "version = \"1.0\">\n" + " <xsl:template match=\"/\">\n" + " <root>\n" + " <xsl:text>\n</xsl:text>\n" + " <xsl:for-each select=\"data/*\">\n" + " <xsl:text>name = `</xsl:text>\n" + " <xsl:value-of select=\"name()\" />\n" + " <xsl:text>`, data = `</xsl:text>\n" + " <xsl:value-of select=\".\" />\n" + " <xsl:text>`\n</xsl:text>\n" + " </xsl:for-each>\n" + " </root>\n" + " </xsl:template>\n" + "</xsl:stylesheet>\n"; OutputDetails output = null; StyleSheet stylesheet = null; output = new OutputDetails(); output.setWriter(new PrintWriter(System.out)); stylesheet = new StyleSheet(); stylesheet.setOutputDetails(output); stylesheet.prepareStyleSheet(new InputSource(new StringReader(xslData))); System.out.println("render 1\n======"); stylesheet.renderSource(new InputSource(new StringReader(xmlData))); System.out.println("\n======"); output = new OutputDetails(); output.setWriter(new PrintWriter(System.out)); stylesheet = new StyleSheet(); stylesheet.setOutputDetails(output); stylesheet.prepareStyleSheet(new InputSource(new StringReader(xslData))); System.out.println("render 2\n======"); stylesheet.renderSource(new InputSource(new StringReader(xmlData))); System.out.println("\n======"); } } /* class SaxonTest */ === END CODE -- Warren Hedley Department of Engineering Science Auckland University New Zealand XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: Using dom.Document as SAXON sou, Kay Michael | Thread | paths starting with "//" are invari, Mark D. Anderson |
java.lang.StackOverflowError in XT , Mike Brown | Date | A new Zvon tutorial and a little ha, Miloslav Nic |
Month |