You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Nils Köster <ni...@lolili.de> on 2004/05/04 11:30:25 UTC

XSLT: Session-Content in Variables

Some weeks ago I comlained about not getting session content in variables in
xslt. I read much about others who had the same problem. Now I found out,
why it doesn't work.

It's not a bug, it's a feature.

What I tried:
---------------------------------
Some.xsl:
---------------------------------
...
<xsl:variable name="lang"><session:getxml context="bct"
path="/context/lang"/></xsl:variable>
...
---------------------------------


My sitemap looked like this:
---------------------------------
<map:pipeline type="noncaching">
	<map:match pattern="rmd_list">
		<map:generate src="content/foo.xml"/>
		<map:transform src="style/xsl/some.xsl"/>      (1)
		<map:transform type="session"/>                (2)
		<map:serialize type="html"/>
	</map:match>
</map:pipeline>
---------------------------------

The simple reason, why there will never be something in the variable while
processing the xsl is, that alle the xsl-stuff (1) (including the usage of
the variable) is done before the session-tags are processed by the
session-transformer (2).

For example:

If I have a <xsl:value-of select="$lang"/> somewhere in some.xsl, cocoon
would first replace this with nothing (1) and afterwards care about the
session-tags (2).

So, using session-content in variables will never work using the
session-transformer.

Any comments?

Regards,
Nils


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


AW: XSLT: Session-Content in Variables

Posted by Nils <co...@lolili.de>.
Hi Joerg,

You're right. In my pipeline i solved it this way:

<map:pipeline type="noncaching">
	<map:match pattern="impressum">
		<map:generate src="content/texts.xml" type="serverpages"/>
		<map:transform type="session"/>
		<map:transform
src="style/xsl/general_content_template.xsl"/>
		<map:serialize type="html"/>
	</map:match>
</map:pipeline>

I put in the session-tags and some xsp-code in the source-xml to care about
the session-stuff and to access it in the xsl-template with some
xpath-expressions.

Your suggestion with:
>    <map:aggregate>
>      <map:part src="content.xml"/>
>      <map:part src="cocoon:/sessioninfo"/>
>    </map:aggregate>

Looks very interesting, i'll try that as well.

Thanks and bye!
Nils


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


Re: XSLT: Session-Content in Variables

Posted by Joerg Heinicke <jo...@gmx.de>.
On 04.05.2004 11:30, Nils Köster wrote:

> Some weeks ago I comlained about not getting session content in variables in
> xslt. I read much about others who had the same problem. Now I found out,
> why it doesn't work.
> 
> It's not a bug, it's a feature.
> 
> What I tried:
> ---------------------------------
> Some.xsl:
> ---------------------------------
> ...
> <xsl:variable name="lang"><session:getxml context="bct"
> path="/context/lang"/></xsl:variable>
> ...
> ---------------------------------
> 
> 
> My sitemap looked like this:
> ---------------------------------
> <map:pipeline type="noncaching">
> 	<map:match pattern="rmd_list">
> 		<map:generate src="content/foo.xml"/>
> 		<map:transform src="style/xsl/some.xsl"/>      (1)
> 		<map:transform type="session"/>                (2)
> 		<map:serialize type="html"/>
> 	</map:match>
> </map:pipeline>
> ---------------------------------
> 
> The simple reason, why there will never be something in the variable while
> processing the xsl is, that alle the xsl-stuff (1) (including the usage of
> the variable) is done before the session-tags are processed by the
> session-transformer (2).
> 
> For example:
> 
> If I have a <xsl:value-of select="$lang"/> somewhere in some.xsl, cocoon
> would first replace this with nothing (1) and afterwards care about the
> session-tags (2).
> 
> So, using session-content in variables will never work using the
> session-transformer.
> 
> Any comments?

Hello Nils,

it seems you mix some things a bit. Though your observation is correct - 
it can not work in that way - IMO your pipeline setup seems to be just 
insufficient.

I never used the session transformer but I guess it expects elements in 
the session namespace as you provided it with <session:getxml/>. The 
problem is that this XML snippet never reaches the session as it never 
gets to see the stylesheet. And you do not add this snippet to the XML 
SAX stream (it's just a result tree fragment in $lang), which the 
session transformer would get to read.

I can imagine two solutions for a working pipeline:

<map:match>
   <map:generate src="content.xml"/>
   <map:transform src="addSessionMarkupToXMLStream.xsl"/>
   <map:transform type="session"/>
   <map:transform src="needsSessionInfoStyling.xsl"/>
   <map:serialize/>
</map:match>

or

<map:match>
   <map:aggregate>
     <map:part src="content.xml"/>
     <map:part src="cocoon:/sessioninfo"/>
   </map:aggregate>
   <map:transform src="needsSessionInfoStyling.xsl"/>
   <map:serialize/>
</map:match>

<map:match pattern="sessioninfo"/>
   <map:generate src="sessionMarkup.xml"/>
   <map:transform type="session"/>
   <map:serialize/>
</map:match>

If you have further questions on this feel free to ask. If it is 
irrelevant because you wanted to express the same, just ignore it :)

Joerg

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