You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Hugo Burm <hu...@xs4all.nl> on 2002/08/25 11:56:42 UTC

Using the extractor transformer with more than one type on the same page

Hello,

I am working on an application that embeds XML definitions for a JFreeChart
chart in my XML content. (for JFreeChart see www.object-refinery.com)

The XML looks like:

<jfc width="500" height="400" xmlns="http://datagram.nl/survey">
... some xml tags that define my chart....
</jfc>

I decided to use the "svg" approach: filtering the svg/jfc tags into a
separate pipeline.

I am using the Cocoon "extractor" transformer to filter my "jfc" fragment.
In my sitemap I modified some parameters of the extractor. E.g.:
<extract-element>jfc</extract-element>

In my "fragment-extractor.xsl" stylesheet I am catching these
"fe.fragment"'s and replacing them with an uri that is matched by the
sitemap. The svg example uses as uri: "some_virtual_map/{$id}.png". And this
png is matched by the sitemap and serialized by svg2png. I created a jfc2png
reader that matches my "some_virtual_map/{$id}.png", builds the jfreechart,
and serializes to png.

The problem: everything works OK until I want to mix svg and jfc on the same
page. The extraction process works fine, but I did not find a way to
differentiate between svg and jfc in my "fragment-extractor.xsl" stylesheet.
So I don't know when to use svg2png and when to use my jfc2png.

The problem is created by the "FragmentExtractorTransformer.java" class.
It knows the name of the element it is filtering, but it does not pass it
any further.
So the easiest solution seems to be to add a new attribute that passes the
name of the filtered element. Somewhere around line 350 of the
"FragmentExtractorTransformer.java" class.

Did I miss something? Is there a way to find out in the
"fragment-extractor.xsl" stylesheet about the element that was extracted? Is
there some other solution? Or do I indeed have to modify the java class as
desscribed above? Or use a quick hack: compile my own version of the
extractor class and use   fj.fragment instead of fe.fragment?

Thanks

Hugo Burm
hugob@datagram.nl


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

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


Re: Using the extractor transformer with more than one type on the same page

Posted by Vadim Gritsenko <va...@verizon.net>.
Hugo Burm wrote:

>Hello,
>
>I am working on an application that embeds XML definitions for a JFreeChart
>chart in my XML content. (for JFreeChart see www.object-refinery.com)
>
>The XML looks like:
>
><jfc width="500" height="400" xmlns="http://datagram.nl/survey">
>... some xml tags that define my chart....
></jfc>
>
>I decided to use the "svg" approach: filtering the svg/jfc tags into a
>separate pipeline.
>
>I am using the Cocoon "extractor" transformer to filter my "jfc" fragment.
>In my sitemap I modified some parameters of the extractor. E.g.:
><extract-element>jfc</extract-element>
>
>In my "fragment-extractor.xsl" stylesheet I am catching these
>"fe.fragment"'s and replacing them with an uri that is matched by the
>sitemap. The svg example uses as uri: "some_virtual_map/{$id}.png". And this
>png is matched by the sitemap and serialized by svg2png. I created a jfc2png
>reader that matches my "some_virtual_map/{$id}.png", builds the jfreechart,
>and serializes to png.
>
>The problem: everything works OK until I want to mix svg and jfc on the same
>page. The extraction process works fine, but I did not find a way to
>differentiate between svg and jfc in my "fragment-extractor.xsl" stylesheet.
>So I don't know when to use svg2png and when to use my jfc2png.
>

Hugo,

You always can do:

- extract SVG
- run your fragment-extractor-svg.xsl
- extract JFC
- run your fragment-extractor-jfc.xsl



>The problem is created by the "FragmentExtractorTransformer.java" class.
>It knows the name of the element it is filtering, but it does not pass it
>any further.
>So the easiest solution seems to be to add a new attribute that passes the
>name of the filtered element. Somewhere around line 350 of the
>"FragmentExtractorTransformer.java" class.
>

Or, you can patch transformer.

Vadim



>Did I miss something? Is there a way to find out in the
>"fragment-extractor.xsl" stylesheet about the element that was extracted? Is
>there some other solution? Or do I indeed have to modify the java class as
>desscribed above? Or use a quick hack: compile my own version of the
>extractor class and use   fj.fragment instead of fe.fragment?
>
>Thanks
>
>Hugo Burm
>hugob@datagram.nl
>  
>



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

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