cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Antony Grinyer" <antony.grin...@csw.co.uk>
Subject RE: XSLT transformation
Date Fri, 05 Aug 2005 09:26:14 GMT
Thanks to everyone's help I believe I'm getting closer to getting this
working...darn...I didn't realize transforming XML in Cocoon could cause
such a problem!  I've now changed my code to:

 private void generateDocumentToSAX(String queryResults)
  {
    try
    {
      XMLReader parser = XMLReaderFactory.createXMLReader();
      parser.setContentHandler(this);
      InputSource inputSource = new InputSource(new
StringReader(queryResults));
      parser.parse(inputSource);
    }
    catch(Exception e)
    {
      m_resultMessage = "Unable to get parser: " + e.toString();
      this.getLogger().error(m_resultMessage);
    }
  }

And I get this error in the sitemap.log:

----
Unable to get parser: java.lang.UnsupportedOperationException: The
TransformerHandler is not serially reusable. The startDocument() method
must be called once only.
-----

I think this might be happening because I pass in XML to the java class
transformer (containing the above method) which finds/creates the
startDocument element in the startElement method, and then the parser in
the method above creates another startDocument element, which is
confusing the saxon xslt transformer? I'm confused here now - if the
purpose of a Cocoon transformer is to take in some XML, change it, then
spit out the changed XML, why are the xlst (saxon, xalan) transformers
complaining about duplicated startDocument elements? Sure you can use a
parser to create Sax events within a transformer java class which
extends the AbstractSAXTransformer class?

Thanks again,
Ant

> -----Original Message-----
> From: Upayavira [mailto:uv@odoko.co.uk] 
> Sent: 05 August 2005 08:08 am
> To: users@cocoon.apache.org
> Subject: Re: XSLT transformation
> 
> <snip/>
> Conal Tuohy wrote:
> >
> > Upayavira wrote:
> >>Your transformer is passing something down the pipeline as 
> null. This 
> >>isn't tripping up the XML serializer, but is tripping up the xslt 
> >>transformer. Go through each of the startElement, etc, calls within 
> >>your transformer looking at the output. See if you can see 
> any nulls 
> >>in there.
> > 
> > 
> > e.g. there is a null passed as the value of a namespace URI to 
> > AttributesImpl.addAttribute
> > 
> > If the namespace URI is null it should be represented by the empty 
> > string ("") not java null.
> 
> Hah. Thanks for that. I suspected it was something simple like that. 
> Confuses XSLT transformers, but the XMLSerializer is okay with it.
> 
> Regards, Upayavira
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 
> 
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message