473,414 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Distinguishing fragments from Cocoon FragmentExtractorTransformer

If I configure and use two different fragment extractors on the
same XML document, how can I write xslt template match
patterns that distinguish which elements these fragments replaced?

Details:

My xml document contains, among other elements, two distinct
elements that need external java processing by a custom-made
Cocoon serializer that converts the contents of these elements
to "other stuff".

To extract each of these elements, I define two fragment extractors
in my sitemap:

<map:transformer name="GoopExtractor"
src="org.apache.cocoon.transformation.FragmentExtr actorTransformer">
<extract-uri>GoopNamespace</extract-uri>
<extract-element>goop</extract-element>
</map:transformer>

<map:transformer name="GleepExtractor"
src="org.apache.cocoon.transformation.FragmentExtr actorTransformer">
<extract-uri>GleepNamespace</extract-uri>
<extract-element>gleep</extract-element>
</map:transformer>

An example xml document might contain:

...
<goop xmlns="GoopNamespace"/>
<goop xmlns="GoopNamespace"/>
<gleep xmlns="GleepNamespace"/>
...
+Lots of other elements handled directly by the stylesheet

The pipeline for the document:

<map:match pattern="**.weird">
<map:generate src="{1}.mxml"/>
<map:transform type="GoopExtractor"/>
<map:transform type="GleepExtractor"/>
<map:transform type="xslt" src="stylesheet.xsl"/>
<map:serialize type="html"/>
</map:match>

The xml seen by the stylesheet will have the goop and gleep elements
replaced by
fe:fragments. Using the sample xml with two goops and one gleep shown above,
the input to the stylesheet would be:

<fe:fragment xmlns="GoopNamespace"
xmlns:fe="http://apache.org/cocoon/fragmentextractor/2.0"
fragment-id="123"/>
<fe:fragment xmlns="GoopNamespace"
xmlns:fe="http://apache.org/cocoon/fragmentextractor/2.0"
fragment-id="456"/>
<fe:fragment xmlns="GleepNamespace"
xmlns:fe="http://apache.org/cocoon/fragmentextractor/2.0"
fragment-id="789"/>

It would be very nice if the FragmentExtractorTransformer put in an
attribute for the
element name it replaced. Something like: fragment-name="goop"
Unfortunately, this is not the case.
Note the apparently spurious default namespace defined in each fe:fragment:
This appears to be the only way to tell which element type the fragment
replaced.

Now for the problem:
I want to have two templates in the stylesheet: One that matches fragments
that replaced the goop elements
and one that matches fragments that replaced the gleep elements. How should
the match patterns be written?
To be totally concrete:

<!-- Template for goop fragments -->

<xsl:template match="fe:fragment?????">
<img src="cocoon/goop/{@fragment-d}.gif/>
</xsl:template>

<!-- Template for gleep fragments -->

<xsl:template match="fe:fragment?????">
<img src="cocoon/gleep/{@fragment-d}.gif/>
</xsl:template>

When the request for the src="..." goes back to the server, the sitemap
matches
it and processes the extracted fragments using a special serializer:

<map:match pattern="goop/*.giif">
<map:generate type="extractor" src="{1}"/>
<map:serialize type="GoopSerializer"/>
</map:match>
<map:match pattern="gleep/*.gif">
<map:generate type="extractor" src="{1}"/>
<map:serialize type="GleepSeializer"/>
</map:match>

The GoopSerializer and GleepSerializer are java programs I write
that transform the information in goops and gleeps into gifs.

Thanks,

Hugh Sparks, hu**@csparks.com
Jul 20 '05 #1
0 1434

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam | last post by:
Hi! I'm trying to do a login form in cocoon. Login data are taken from MySQL, but before the data are checked cocoon throws such an error: org.apache.cocoon.ResourceNotFoundException: Resource...
1
by: Jawahar | last post by:
Hi All.. Currently in our application, we are using Serlvet as Controller,Jsp to View,BusinessLogic in EJB. We planned to implement Cocoon frame work in our existing application. Is this...
6
by: Jeremy | last post by:
My requirements are very simple: When a user browses to an XML document, the server should parse the document, apply its stylesheet, and spit the HTML at the client. Apache Cocoon is a slow,...
0
by: wai | last post by:
hi all, i running cocoon 2.1.1 with websphere 5, i have a problem related to xsp cinclude. everything after my first cinclude statement, it become bank. i been tested the cocoon cinclude...
0
by: mcv | last post by:
I'm currently learning to use Cocoon, and although I really like it, there are a couple of things that don't seem to be explained very well. I've seen lots of articles explaining really complicated...
0
by: Per-Christian Engdal | last post by:
Hi, I have built a cocoon.war file, and deployed it on my BEA Weblogic 8.1 Sp2 (Windows 2000) installation. The deployment works without exceptions, but when I try to access cocoon through...
2
by: rozwel | last post by:
Hi, I'm currently starting a CMS project based on XML-related technologies and I want to use an XML framework as the basis of my architecture. I found two open source project that could fit my...
3
by: Dennis Benzinger | last post by:
Hi! Is there a Python web publishing framework like Cocoon? I found Maki <http://maki.sourceforge.net/> but it was last updated in 2003 and its author says that he doesn't want to make another...
0
by: Hugh Field-Richards | last post by:
Hi This was original posted only on the Cocoon Users Group last year but Paloose is now reasonably mature enough for exposure on this forum. Paloose is a simplified (much simplified) version...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.