You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Martin Kavalar <ka...@bokowsky.de> on 2001/09/07 13:51:17 UTC

Problem with own Generator and XSLT

Hello,
For a project we are working on, we are implementing our own generator, 
which is supposed to combine multiple input sources (XML-FS, OODB, RDB, 
...) and output one XML. We started out with the generator having all 
XML hardcoded in our generator, so it would look like this:

public void generate() throws IOException, SAXException, 
ProcessingException {
....
// xmlConsumerAdapter calls xmlConsumer
this.xmlConsumerAdapter.startNSElement("info", "title");
this.xmlConsumerAdapter.characters("MuX [" + 
this.parameters.getParameter("OutputType", "NULL") + "]");
this.xmlConsumerAdapter.endNSElement("info", "title");

...and so on

We then copied a part of our xml output (The part containing the 
navigation) and moved it to a xml file on the filesystem.
No matter what way we tried to include this file however and send it to 
the xml consumer, no xsl transformation of any elements below the 
included navigation occurred.
We then implemented a way of turning compents in the xml output of, so 
cocoon/myproject?nav=0 would simply not include the nav file, then all 
other elements would be transformed.
Is this a bug in cocoon? (We reported it as #3057) What would be the 
correct to send xml code from the filesystem to xmlConsumer?
Here is what we tried:

1.
//nav File is a String to the existing nav file
Source is = resolver.resolve(navFile);
is.toSAX(this.xmlConsumer);

2.
XMLReader xr = XMLReaderFactory.createXMLReader();
xr.setContentHandler(super.xmlConsumer);
xr.parse(new InputSource(new FileReader(navFile)));

Thanks a lot for your help!
martin


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


Re: AW: Problem with own Generator and XSLT

Posted by Martin Kavalar <ka...@bokowsky.de>.
Thank you so much, its working perfectly now. It must have been the 
startDocument() that caused the transformation to stop.
I just closed the bug, sorry if anyone wasted time on my error.
thanks once more
martin

Carsten Ziegeler wrote:

>Hi,
>
>1. did you try to read and transform your file using the standard
>   file generator? (in sitemap: <map:generate src="file.xml"/>)
>2. If you include an xml source inside your generator into your
>   stream, your first approach (using toSAX()) is the way to go,
>   but when using toSAX() (or any other method), all sax events
>   for parsing this document are send, including the startDocument()
>   and endDocument() event.
>   So if you include this, you have to ignore those two sax events.
>   For exactly this purpose exists the
>org.apache.cocoon.xml.IncludeXMLConsumer
>   class.
>
>If 1. does not work, it may be that your stylesheet is the source
>of error.
>If you still have problems, include your xml and xsl file if possible.
>
>Carsten
>
>>-----Ursprungliche Nachricht-----
>>Von: Martin Kavalar [mailto:kavalar@bokowsky.de]
>>Gesendet: Freitag, 7. September 2001 13:51
>>An: cocoon-users@xml.apache.org
>>Betreff: Problem with own Generator and XSLT
>>
>>
>>Hello,
>>For a project we are working on, we are implementing our own generator,
>>which is supposed to combine multiple input sources (XML-FS, OODB, RDB,
>>...) and output one XML. We started out with the generator having all
>>XML hardcoded in our generator, so it would look like this:
>>
>>public void generate() throws IOException, SAXException,
>>ProcessingException {
>>....
>>// xmlConsumerAdapter calls xmlConsumer
>>this.xmlConsumerAdapter.startNSElement("info", "title");
>>this.xmlConsumerAdapter.characters("MuX [" +
>>this.parameters.getParameter("OutputType", "NULL") + "]");
>>this.xmlConsumerAdapter.endNSElement("info", "title");
>>
>>...and so on
>>
>>We then copied a part of our xml output (The part containing the
>>navigation) and moved it to a xml file on the filesystem.
>>No matter what way we tried to include this file however and send it to
>>the xml consumer, no xsl transformation of any elements below the
>>included navigation occurred.
>>We then implemented a way of turning compents in the xml output of, so
>>cocoon/myproject?nav=0 would simply not include the nav file, then all
>>other elements would be transformed.
>>Is this a bug in cocoon? (We reported it as #3057) What would be the
>>correct to send xml code from the filesystem to xmlConsumer?
>>Here is what we tried:
>>
>>1.
>>//nav File is a String to the existing nav file
>>Source is = resolver.resolve(navFile);
>>is.toSAX(this.xmlConsumer);
>>
>>2.
>>XMLReader xr = XMLReaderFactory.createXMLReader();
>>xr.setContentHandler(super.xmlConsumer);
>>xr.parse(new InputSource(new FileReader(navFile)));
>>
>>Thanks a lot for your help!
>>martin
>>
>>
>>---------------------------------------------------------------------
>>Please check that your question has not already been answered in the
>>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>>
>>To unsubscribe, e-mail: <co...@xml.apache.org>
>>For additional commands, e-mail: <co...@xml.apache.org>
>>
>
>
>---------------------------------------------------------------------
>Please check that your question has not already been answered in the
>FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
>To unsubscribe, e-mail: <co...@xml.apache.org>
>For additional commands, e-mail: <co...@xml.apache.org>
>
>



---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>


AW: Problem with own Generator and XSLT

Posted by Carsten Ziegeler <cz...@sundn.de>.
Hi,

1. did you try to read and transform your file using the standard
   file generator? (in sitemap: <map:generate src="file.xml"/>)
2. If you include an xml source inside your generator into your
   stream, your first approach (using toSAX()) is the way to go,
   but when using toSAX() (or any other method), all sax events
   for parsing this document are send, including the startDocument()
   and endDocument() event.
   So if you include this, you have to ignore those two sax events.
   For exactly this purpose exists the
org.apache.cocoon.xml.IncludeXMLConsumer
   class.

If 1. does not work, it may be that your stylesheet is the source
of error.
If you still have problems, include your xml and xsl file if possible.

Carsten

> -----Ursprungliche Nachricht-----
> Von: Martin Kavalar [mailto:kavalar@bokowsky.de]
> Gesendet: Freitag, 7. September 2001 13:51
> An: cocoon-users@xml.apache.org
> Betreff: Problem with own Generator and XSLT
>
>
> Hello,
> For a project we are working on, we are implementing our own generator,
> which is supposed to combine multiple input sources (XML-FS, OODB, RDB,
> ...) and output one XML. We started out with the generator having all
> XML hardcoded in our generator, so it would look like this:
>
> public void generate() throws IOException, SAXException,
> ProcessingException {
> ....
> // xmlConsumerAdapter calls xmlConsumer
> this.xmlConsumerAdapter.startNSElement("info", "title");
> this.xmlConsumerAdapter.characters("MuX [" +
> this.parameters.getParameter("OutputType", "NULL") + "]");
> this.xmlConsumerAdapter.endNSElement("info", "title");
>
> ...and so on
>
> We then copied a part of our xml output (The part containing the
> navigation) and moved it to a xml file on the filesystem.
> No matter what way we tried to include this file however and send it to
> the xml consumer, no xsl transformation of any elements below the
> included navigation occurred.
> We then implemented a way of turning compents in the xml output of, so
> cocoon/myproject?nav=0 would simply not include the nav file, then all
> other elements would be transformed.
> Is this a bug in cocoon? (We reported it as #3057) What would be the
> correct to send xml code from the filesystem to xmlConsumer?
> Here is what we tried:
>
> 1.
> //nav File is a String to the existing nav file
> Source is = resolver.resolve(navFile);
> is.toSAX(this.xmlConsumer);
>
> 2.
> XMLReader xr = XMLReaderFactory.createXMLReader();
> xr.setContentHandler(super.xmlConsumer);
> xr.parse(new InputSource(new FileReader(navFile)));
>
> Thanks a lot for your help!
> martin
>
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
>


---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>