You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by qMax <qm...@mediasoft.ru> on 2004/08/19 08:16:55 UTC
newby Q: how to aggregate source in resource
I want to set up my pipelines with final stage "page-html-format"
called from resource:
<map:pipeline>
<map:match>
<map:generate ... />
<map:transform ... />
<map:call resource name="format-page.html"/>
</map:match>
</map:pipeline>
But this "format-page.html" should aggregate various other sources:
<map:resource name="format-page.html">
<map:aggregate element='page'>
<map:part>this part should be output from original pipeline</map:part>
<map:part src='cocoon:/menu.xml'/>
<map:part src='cocoon:/foo.xml'/>
<map:part src='cocoon:/bar.xml'/>
</map:aggregate>
<map:transform ... />
<map:serialize type="html"/>
</map:resource>
Currently, i do not use resource like this,
but instead use global matching pipeline with pattern="**.html"
which has <map:part src="**.original-html"/>
and all other pipelines should match "something.original-html"/>
This looks ugly...
Is this better solution ?
More general:
I need main page template (currently i use XSLT) which uses (and slightly transforms)
original HTML content and content from some other sources (currently i
use map:aggregate as input to this XSLT)
and should produce final HTML with menu and all that stuff.
--
qMax
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: newby Q: how to aggregate source in resource
Posted by "Volkm@r" <pl...@arcor.de>.
qMax wrote:
> [...]
> Oh! Thanks! This solution has slept from my view.
>
> But actually included content is not ready-to-use HTML, but is XML to
> integrate into final HTML via XSLT. In particular - block "meta" has
> additional xml-info about current site node ("page"), and is
> dependant on current request URL and request parameters.
>
> so, i probably should use something like: <ci:include
> src="cocoon:/meta-info?resource={$original-request-uri}&{$original-request-param-string}"/>
>
>
Did you consider preparing those stuff to be included in a separate
match like following with pattern="*.metainfo"?
=============================
<map:pipeline>
<map:match pattern="*.metainfo">
<!-- prepare meta-info -->
</map:match>
<map:match>
<map:generate src="original XHTML" />
<map:transform src="include-things.xsl">
<map:parameter name="whatyoulike" value="..." />
</map:transform>
<map:transform type="cinclude"/>
<map:transform type="remove-namespace" />
<map:serialize/>
</map:match>
</map:pipeline>
=============================
And in XSLT:
===============================
<xsl:param name="whatyoulike"/>
<xsl:template match="*[local-name()='body']">
<xsl:copy>
<ci:include src="cocoon:/{$whatyoulike}.metainfo"/>
<div id="content">
<xsl:apply-templates select="@*|node()"/>
</div>
</xsl:copy>
</xsl:template>
===============================
--
Volkmar W. Pogatzki
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re[2]: newby Q: how to aggregate source in resource
Posted by qMax <qm...@mediasoft.ru>.
Thursday, August 19, 2004, 4:11:31 PM, plsdontreply@arcor.de wrote:
Vr> qMax wrote:
>> [...]
>> More general:
>> I need main page template (currently i use XSLT) which uses (and slightly transforms)
>> original HTML content and content from some other sources (currently i
>> use map:aggregate as input to this XSLT)
>> and should produce final HTML with menu and all that stuff.
>>
Vr> What about include?
Vr> =============================
Vr> <map:pipeline>
Vr> <map:match>
Vr> <map:generate src="original XHTML" />
Vr> <map:transform src="include-things.xsl" />
Vr> <map:transform type="cinclude"/>
Vr> <map:transform type="remove-namespace" />
Vr> <map:serialize/>
Vr> </map:match>
Vr> </map:pipeline>
Vr> =============================
Oh! Thanks!
This solution has slept from my view.
But actually included content is not ready-to-use HTML, but is XML to integrate
into final HTML via XSLT.
In particular - block "meta" has additional xml-info about current site node ("page"),
and is dependant on current request URL and request parameters.
so, i probably should use something like:
<ci:include src="cocoon:/meta-info?resource={$original-request-uri}&{$original-request-param-string}"/>
Or use some another concept of retrieving meta-info.
--
qMax
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: newby Q: how to aggregate source in resource
Posted by "Volkm@r" <pl...@arcor.de>.
qMax wrote:
> [...]
> More general:
> I need main page template (currently i use XSLT) which uses (and slightly transforms)
> original HTML content and content from some other sources (currently i
> use map:aggregate as input to this XSLT)
> and should produce final HTML with menu and all that stuff.
>
What about include?
=============================
<map:pipeline>
<map:match>
<map:generate src="original XHTML" />
<map:transform src="include-things.xsl" />
<map:transform type="cinclude"/>
<map:transform type="remove-namespace" />
<map:serialize/>
</map:match>
</map:pipeline>
=============================
The first transformation "include-things.xsl" would match the places
where to add additional content.
There are three templates, the first putting link elements into the head
element, second which adds a menu at the beginning of the body element
and last which is identical copy of anything else.
Using [local-name] will only be necessary if your original XHTML has a
namespace.
The output will have an additional namespace that has to be removed in a
next step.
=============================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ci="http://apache.org/cocoon/include/1.0">
<xsl:template match="*[local-name()='head']">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<ci:include src="cocoon:/ source for navigation toolbar"
select="links/*"
ns="http://www.w3.org/1999/xhtml"/>
</xsl:copy>
</xsl:template>
<xsl:template match="*[local-name()='body']">
<xsl:copy>
<ci:include src="cocoon:/ source-for-menu "/>
<div id="content">
<xsl:apply-templates select="@*|node()"/>
</div>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
=============================
Now remove xmlns:ci="http://apache.org/cocoon/include/1.0" from the output
=============================
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="/|comment()|processing-instruction()">
<xsl:copy>
<!-- go process children (applies to root node only) -->
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<!-- Second attribute creating new namespace. -->
<xsl:element name="{local-name()}"
xmlns="http://www.w3.org/1999/xhtml">
<!-- go process attributes and children -->
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{local-name()}">
<xsl:value-of select="."/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
=============================
--
Volkmar W. Pogatzki
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org