[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Using XSLProcessor.parse(InputStream source) with XT 1999110

Subject: Using XSLProcessor.parse(InputStream source) with XT 19991105
From: Diarmuid Mac Carthy <Diarmuid@xxxxxxxx>
Date: Mon, 15 Nov 1999 19:19:36 -0000
pipedoutputstream xml
Hi,

I'm trying to reparse the result of an XSLT transformation, but with little
success.  This
is a pretty long mail but I hope it has enough information to describe my
problem in 
enough detail that somebody can understand it and hopefully shed some
light...

Briefly, the changes I've made are:

* Registered a PipedOutputStream with XMLOutputHandler and replaced 
     OutputStream out = ...
  with
     PipedOutputStream out = 
        new PipedOutputStream(XSLPipedInputStream.getInstance());

* XSLPipedInputStream is a singleton class I've written that extends
java.io.PipedInputStream and intercepts the output from XMLOutputHandler

* XTDriver is a modification on com.jclark.xsl.sax.Driver which gets a
handle on the 
  output from XMLOutputHandler:

     PipedInputStream m_XMLInputStream = XSLPipedInputStream.getInstance();

The principal is basic and works:

XMLOutputHandler ----> PipedOutputStream ----> XSLPipedInputStream ---> main
driver

*  XMLOutputHandler writes to a PipedOutputStream which is connected to a
singleton
   instance of XSLPipedInputStream which in turn is used by the driver
class.  I've
   included an extra method on this class which returns the internal
PipedInputStream 
   buffer:

      public byte[] getStream() {
           return buffer;
       }

    When I process an XML doc with an XSLT script, I can access the
resulting doc and 
    print it out from the driver class:

         m_xsl.loadStylesheet(fileInputSource(p_inXSLFile));
         m_xsl.parse(fileInputSource(p_inXMLFile));         

         System.out.println("Transformed XML:" + 
              new String(m_XMLInputStream.getStream());

    and the expected transformations have happened.

    I've included the XML and XSLT scripts below to show the simple an
example I'm 
    trying to get working.

    The XML:

    <MESSAGE>
       <DATA>
          <ADDRESS>hello</ADDRESS>
       </DATA>
    </MESSAGE>

    The XSL:

    <?xml version="1.0"?>
    <xsl:stylesheet 
         version="1.0" 
         xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" omit-xml-declaration="no"/>

      <xsl:template match="/">
        <xsl:copy-of select=".">
           <xsl:apply-templates
               select = "*|@*|comment()|processing-instruction()|text()"/>
           </xsl:copy-of>
        </xsl:template>
      </xsl:stylesheet>   


    So the initial transformation works fine, but when I try and redirect
that transformed
    output back into the XSLProcessorImpl it falls down:

       m_xsl.loadStylesheet(fileInputSource(p_inXSLFile));
       m_xsl.parse(fileInputSource(p_inXMLFile));         

       // And instead of printing the transformed output out, rerun the
output against
       // the current sheet, so we'd expect to see exactly the same output a
second
       // time round

       BufferedReader l_br =
              new BufferedReader(new InputStreamReader(m_XMLOutputStream));
       InputSource l_source = new InputSource(l_br);
       l_source.setEncoding("UTF-8");

       // m_xsl is an instance of XSLProcessorImpl.  
       m_xsl.parse(l_source);

   This just hangs.  I've debugged it and traced the problem down to
      package com.jclark.xml.parse.EntityParser.parseDocumentEntity which
seems to
   hang inexplicably on the parseMisc() operation.  I've examined the
variables associated
   with this and confirmed that the encoding class is UTF8Encoding.  It
falls over on
  	switch (tokenizeProlog()) {
   within parseMisc() which can't be evaluated when reparsing the
transformed XML, although
   it works fine on the original first run...

  
I'm completely stumped...I've checked through the XSL-List archives and
tried various
combinations of encoding schemes and systemIds, using BufferedInputStream
and ByteArrayInputStream in place of the Reader idea, but to no avail.

If anybody has come across this or can shed some light on the problem I'd
really appreciate it.

Best regards,
Diarmuid

         

Diarmuid Mac Carthy
XIAM Ltd. "The 'Information Router' company
12 Hume Street, Dublin 2, Ireland.
ph: +353 1 638 4858
fx:  +353  1 678 9070
email:  diarmuid@xxxxxxxx
www:  www.xiam.com
 
This document is strictly confidential and is intended for use by the
addressee unless otherwise indicated.
 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.