cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joerg Heinicke <joerg.heini...@gmx.de>
Subject Re: Cocoon, XML:DB and custom generator problem
Date Fri, 30 Apr 2004 00:43:51 GMT
On 28.04.2004 17:58, Christian Rosenberger wrote:

> The result is in a XMLResource instance.
> 
> Part of my custom generator code:
> 
>         this.contentHandler.startDocument();
>         for (long i = 0; i < result.getSize(); i++)
>         {
>                 resource = (XMLResource)
>                 result.getResource(i);
>                 resource.getContentAsSAX(this.contentHandler);
>         }
>         this.contentHandler.endDocument();
> 
> 
> So I have two results in my ResourceSet. (one for each user). I am browsing
> these results and for each XMLResource in the ResourceSet I call the
> getContentAsSax method.
> 
> The result is a nonvalid XML document with two <?xml..> tags:

Is only the XML declaration the problem or are there more, e.g. multiple 
root elements?

> Any ideas what is going wrong in my Java code? Tried to call the
> startElement method after calling the startDocument, but have also no
> success with it!

Don't understand the last sentence.

You might need to put another ContentHandler into the pipe that just 
ignores startDocument() and endDocument():

ContentHandler myContentHandler = new MyContentHandler(this.contentHandler);
this.contentHandler.startDocument();
for (long i = 0; i < result.getSize(); i++)
{
     resource = (XMLResource)
     result.getResource(i);
     resource.getContentAsSAX(myContentHandler);
}
this.contentHandler.endDocument();



private class MyContentHandler implements ContentHandler {

     private ContentHandler ch;

     MyContentHandler(ContentHandler ch) {
         this.ch = ch;
     }

     startDocument() {
         //ignore
     }

     endDocument() {
         //ignore
     }

     allOtherMethodsFromContentHandler() {
         this.ch.allOtherMethodsFromContentHandler();
     }
}

Joerg

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


Mime
View raw message