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/09/11 18:38:02 UTC

RE: general use FragmentExtractor transformer?

Hello Artur,

Yes, you can use the standard cocoon FragmentExtractor as long as you don't
want to mix your own elements and svg on the same page (you will run into
problems at step 3 below. You can solve that by adding one line of code to
the standard cocoon source and pass the element-name that is extracted as an
attribute to step 3)

The example below is from a working site.
But I removed the authorization part and flattened the directory structure
to make it easier to read and understand.
Hope I did not make a misstake...

The namespace (datagram.nl in the example) is not critical, but make sure it
is consistent in all your documents


Hugo Burm
hugob@datagram.nl

=================================


Main xml
========

<bookmarks xmlns="http://datagram.nl/survey>
 <folder>
  ...
 </folder>
 <folder>
  ...
 </folder>
</bookmarks>

Sitemap
=======
1) Define a Tranformer with a unique name and define its uri and element

<map:transformer logger="sitemap.transformer.extractor" name="j-extractor"
src="org.apache.cocoon.transformation.FragmentExtractorTransformer">
     		<extract-uri>http://datagram.nl/survey</extract-uri>
	    	<extract-element>bookmarks</extract-element>
</map:transformer>

2a) Set up the pipeline

<map:match pattern="status">
    <map:generate type="serverpages" src="status.xsp"/>
    <map:transform type="j-extractor"/>
    <map:transform type="xslt" src="style/fragment-extractor.xsl"/>
    <map:transform type="xslt" src="style/simple.xsl"/>
    <map:serialize/>
</map:match>


2b) Make sure you extracted fragment will be converted to xml

<map:match pattern="fragments/*.xml">
    <map:generate src="{1}" type="extractor"/>
    <map:serialize type="xml"/>
</map:match>

3) Create fragment-extractor.xml
=================================
	<xsl:template match="//fe:fragment">
		<a href="fragments/{@fragment-id}.xml"><xsl:value-of
select="@fragment-id"/>.xml</a>
	</xsl:template>




-----Original Message-----
From: Artur Matos [mailto:amatos@create.human.nagoya-u.ac.jp]
Sent: Wednesday, September 11, 2002 8:37 PM
To: cocoon-users@xml.apache.org
Subject: general use FragmentExtractor transformer?


Hi to all,

I have a small web site that I am maintaining
using Cocoon in offline mode. Now I have stumbled
with this problem: I want to be able to extract
all of the subtrees from a big XML file and feed
each of them into a different pipeline.I think it can be
better understood using an example: If I have a XML file
similar to this:

<bookmarks>
 <folder>
  ...
 </folder>
 <folder>
  ...
 </folder>
</bookmarks>

I want to be able to extract the <folder> subtrees and
feed each of them into a different pipeline, (and if possible)
changing the original ones in the document by a <link> tag. If I
understand correctly, this is what the FragmentExtractor does, but
it only works with embedded SGV. So, can I do the above
using the FragmentExtractor pair or another standard/third party
Cocoon transformer? Should I create my own transformer for this?

Thanks in advance,

Artur Matos.

---------------------------------------------------------------------
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>



---------------------------------------------------------------------
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>