views:

481

answers:

2

Hey there,

My problem is to setup the Cocoon sitemap.xmap in a way, that it first makes a transformation of an XML file with XSL, which I can then use for my own transformation.

I have following files:

start.xml : Contains references of files which are put together applying combine_start.xsl

transform.xsl: This is my own XSL file which I want to use on the transformation made with the combine_start.xsl (output XML)

Since start.xml is kind of an index for all the files needed in the process, the following sitemap wont show any results, if any XSL functions are applied (no tags are found). I've search the net, but I havent found a way to setup a pipeline which first makes a transformation, before applying another transformation.

Hopefully my problem istn too confusing and I appreciate any help I can get. Below you'll find the sitemap I tried.

<?xml version="1.0"?>
<map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"&gt;

 <map:pipelines>

  <map:pipeline>

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="transform.xsl">
       <map:parameter name="X" value="{request-param:X}"/>
       <map:parameter name="Semester" value="{request-param:Semester}"/>
       <map:parameter name="Name" value="{request-param:Name}"/>
       <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

  </map:pipeline>
 </map:pipelines>
</map:sitemap>
+1  A: 

You can transform multiple times. just call map:transform again (with a different xsl) - before you serialize.

you can also use map:part/map:aggregate to mash together multiple matcher and then apply a map:transform on them (or the i:include transformer).

I dont really know what you mean with "no tags found", so maybe i am addressing the question wrong.

--

if you want to see debug output (ie. what exactly is generated based on the xml, you should work with views - declare it in the sitemap (see: http://cocoon.apache.org/2.0/userdocs/concepts/views.html) and add a label to your transformer. you can then see exactly what data is being used for the xsl by calling url?cocoon-view=YOURLABEL

Niko
OK, I'll try it.The origin in my problem is, that I cannot use e.g. xsl:value-of in my transformation. I think its because of the start.xml which only contains references to all the xml files needed for the first transformation and therefore the "tree tags"/properties/names are not found, meaning I get an empty result.
normally when the xsl doesnt produce any output its because its unparseable. check the cocoon-core.log and reduce the xsl to a really small one (just <xsl:template match="/"><xsl:value-of select="'TEST'"/></xsl:emplate> )if you still dont get any output its a configuration problem (aggain cocoon-core.log is your friend)
Niko
I generally find that using JX templates is easier than dealing with map:aggregate. It's a lot more flexible.
Dominic Mitchell
A: 

Michael doesn't seem to be a user anymore, but I'll answer this anyway. Basically adding code to illustrate to Niko's answer, and being a little more specific.

The way to apply transform.xsl to the output of combine_start.xsl [ObHalfLife2Reference] is:

   <map:match pattern="*">
     <map:generate src="start.xml"/>
     <map:transform src="combine_start.xsl" />
     <map:transform src="transform.xsl">
             <map:parameter name="X" value="{request-param:X}"/>
             <map:parameter name="Semester" value="{request-param:Semester}"/>
             <map:parameter name="Name" value="{request-param:Name}"/>
             <map:parameter name="XXX" value="{request-param:XXX}"/>
     </map:transform>
     <map:serialize/>
   </map:match>

If I understand you to be saying that the output of combine_start.xsl is empty, then that's not a Cocoon issue but an XSLT issue... your combine_start.xsl is not working correctly.

Given that start.xml is an index of files to feed into transform.xsl, the cinclude transformer is probably what you are looking for, rather than implementing a stylesheet to slurp them in. On the other hand if the contents of start.xml will never change, then as mentioned above, <map:aggregate> would be more efficient.

LarsH