You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Nick Airey <ni...@ihavemoved.com> on 2002/09/10 17:28:40 UTC

aggregator element question

Hi everyone, 

I posted this earlier on the users' list, and no reply. So here it is for the gurus.



Question: when using the aggregator, is it possible to specify an attribute as
well as the name of the parent element, eg if I have:


<map:match pattern="about">

 <map:aggregate element="page">
  <map:part src="cocoon:/info"/>
  <map:part type="file" src="otherInfo.xml"/>
 </map:aggregate>

 <map:serialize/>
</map:match>

it will give me something like

<page>
 <info/>
 <otherInfo/>
</page>

whereas I would like

<page type="nicks_info_page">
 <info/>
 <otherInfo/>
</page>


Is this possible? I'm using cocoon 2.0.2

Kind regards,
Nick




---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


Re: aggregator element question

Posted by Giacomo Pati <gi...@apache.org>.
On 10 Sep 2002, Nick Airey wrote:

>
> Hi everyone,
>
> I posted this earlier on the users' list, and no reply. So here it is for the gurus.
>
>
>
> Question: when using the aggregator, is it possible to specify an attribute as
> well as the name of the parent element, eg if I have:
>
>
> <map:match pattern="about">
>
>  <map:aggregate element="page">
>   <map:part src="cocoon:/info"/>
>   <map:part type="file" src="otherInfo.xml"/>
>  </map:aggregate>
>
>  <map:serialize/>
> </map:match>
>
> it will give me something like
>
> <page>
>  <info/>
>  <otherInfo/>
> </page>
>
> whereas I would like
>
> <page type="nicks_info_page">
>  <info/>
>  <otherInfo/>
> </page>
>
>
> Is this possible? I'm using cocoon 2.0.2

No.

Giacomo


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: aggregator element question

Posted by Conal Tuohy <co...@paradise.net.nz>.
oh no! an error in my example:

> <xsl:variable name="root-page-type"/>
> 
> <xsl:template match="/page">
> 	<page type="{$root-page-type}">
> 		<xsl:copy-of select="*"/>
> 	</page>
> </xsl:template>

it should be xsl:param not xsl:variable, e.g.

<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  version="1.0">
  
	<xsl:param name="root-page-type"/>

	<xsl:template match="/page">
		<page type="{$root-page-type}">
			<xsl:copy-of select="*"/>
		</page>
	</xsl:template>

</xsl:stylesheet>


---------------------------------------------------------------------
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: aggregator element question

Posted by Conal Tuohy <co...@paradise.net.nz>.
> Question: when using the aggregator, is it possible to
> specify an attribute as
> well as the name of the parent element, eg if I have:
>
>
> <map:match pattern="about">
>
>  <map:aggregate element="page">
>   <map:part src="cocoon:/info"/>
>   <map:part type="file" src="otherInfo.xml"/>
>  </map:aggregate>
>
>  <map:serialize/>
> </map:match>
>
> it will give me something like
>
> <page>
>  <info/>
>  <otherInfo/>
> </page>
>
> whereas I would like
>
> <page type="nicks_info_page">
>  <info/>
>  <otherInfo/>
> </page>
>
>
> Is this possible? I'm using cocoon 2.0.2

It seems not. But you could add the attribute AFTER aggregation, using an
XSL transform.

You sitemap would look like this:

 <map:match pattern="about">

  <map:aggregate element="page">
   <map:part src="cocoon:/info"/>
   <map:part type="file" src="otherInfo.xml"/>
  </map:aggregate>

  <!-- set the "type" attribute of the root "page" element -->
  <map:transform src="set-root-page-type.xsl">
   <map:parameter name="root-page-type" value="nicks_info_page"/>
  </map:transform>

  <map:serialize/>
 </map:match>

... and in the stylesheet (set-root-page-type.xsl) you would have:

...
<xsl:variable name="root-page-type"/>

<xsl:template match="/page">
	<page type="{$root-page-type}">
		<xsl:copy-of select="*"/>
	</page>
</xsl:template>

XSLT is your friend! ;-)

Con


---------------------------------------------------------------------
To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org
For additional commands, email: cocoon-dev-help@xml.apache.org


RE: aggregator element question

Posted by Conal Tuohy <co...@paradise.net.nz>.
> Question: when using the aggregator, is it possible to
> specify an attribute as
> well as the name of the parent element, eg if I have:
>
>
> <map:match pattern="about">
>
>  <map:aggregate element="page">
>   <map:part src="cocoon:/info"/>
>   <map:part type="file" src="otherInfo.xml"/>
>  </map:aggregate>
>
>  <map:serialize/>
> </map:match>
>
> it will give me something like
>
> <page>
>  <info/>
>  <otherInfo/>
> </page>
>
> whereas I would like
>
> <page type="nicks_info_page">
>  <info/>
>  <otherInfo/>
> </page>
>
>
> Is this possible? I'm using cocoon 2.0.2

It seems not. But you could add the attribute AFTER aggregation, using an
XSL transform.

You sitemap would look like this:

 <map:match pattern="about">

  <map:aggregate element="page">
   <map:part src="cocoon:/info"/>
   <map:part type="file" src="otherInfo.xml"/>
  </map:aggregate>

  <!-- set the "type" attribute of the root "page" element -->
  <map:transform src="set-root-page-type.xsl">
   <map:parameter name="root-page-type" value="nicks_info_page"/>
  </map:transform>

  <map:serialize/>
 </map:match>

... and in the stylesheet (set-root-page-type.xsl) you would have:

...
<xsl:variable name="root-page-type"/>

<xsl:template match="/page">
	<page type="{$root-page-type}">
		<xsl:copy-of select="*"/>
	</page>
</xsl:template>

XSLT is your friend! ;-)

Con


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