You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by daniel meier <kr...@krims.ch> on 2002/07/28 09:03:07 UTC

newbie: xsl - xsp - transformation

hi there





I'm using the stream-generator, which produces this document:
the sitemap looks like this:

<map:match pattern="**.req">
<map:generate type="stream"/>
<map:transform src="stylesheets/req2xml.xsl"/>
<map:serialize type="xml"/>
</map:match>


the stream gives sends this to the stylesheet:

<login><username>daniel</username><password>thepassword</password></login>

then I'm doing some xsl-transformation:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="login">
  <xsp:page create-session="yes" language="java"
xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-session="http://apache.org/xsp/session/2.0">
    <loginreply>
      <xsp-session:set-attribute
name="username">krams@krims.ch</xsp-session:set-attribute>
      <xsp-session:set-max-inactive-interval interval="500"/>
      <status>ok</status>
      <sessionid><xsp-session:get-id /></sessionid>
      <username><xsp-session:get-attribute name="username"/></username>
    </loginreply>
  </xsp:page>
</xsl:template>

<xsl:template match="@*|*|text()|processing-instruction()">
  <xsl:copy>
    <xsl:apply-templates select="@*|*|text()|processing-instruction()" />
  </xsl:copy>
</xsl:template>

</xsl:stylesheet>



I get the following back:

<xsp:page xmlns:xsp="http://apache.org/xsp"
xmlns:xsp-session="http://apache.org/xsp/session/2.0" language="java"
create-session="yes">
<loginreply>
  <xsp-session:set-attribute
name="username">krams@krims.ch</xsp-session:set-attribute>
  <xsp-session:set-max-inactive-interval interval="500" />
  <status>ok</status>
  <sessionid><xsp-session:get-id /></sessionid>
  <username><xsp-session:get-attribute name="username" /></username>
</loginreply>
</xsp:page>

which is perfectly ok.

but now how do I tell cocoon that it processes the xsp and the xsp-session
stuff? as I understood I cannot use a second generator.
do I have to create some kind of logicsheet? if yes, how should it look
like?

kind regards

daniel





---------------------------------------------------------------------
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: newbie: xsl - xsp - transformation

Posted by Vadim Gritsenko <va...@verizon.net>.
> From: daniel meier [mailto:krams@krims.ch]
> 
> hi there
> 
> 
> 
> 
> 
> I'm using the stream-generator, which produces this document:
> the sitemap looks like this:
> 
> <map:match pattern="**.req">
> <map:generate type="stream"/>
> <map:transform src="stylesheets/req2xml.xsl"/>
> <map:serialize type="xml"/>
> </map:match>
> 
> 
> the stream gives sends this to the stylesheet:
> 
>
<login><username>daniel</username><password>thepassword</password></logi
n>
> 
> then I'm doing some xsl-transformation:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> 
> <xsl:template match="login">
>   <xsp:page create-session="yes" language="java"
> xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0">
>     <loginreply>
>       <xsp-session:set-attribute
> name="username">krams@krims.ch</xsp-session:set-attribute>
>       <xsp-session:set-max-inactive-interval interval="500"/>
>       <status>ok</status>
>       <sessionid><xsp-session:get-id /></sessionid>
>       <username><xsp-session:get-attribute
name="username"/></username>
>     </loginreply>
>   </xsp:page>
> </xsl:template>
> 
> <xsl:template match="@*|*|text()|processing-instruction()">
>   <xsl:copy>
>     <xsl:apply-templates select="@*|*|text()|processing-instruction()"
/>
>   </xsl:copy>
> </xsl:template>
> 
> </xsl:stylesheet>
> 
> 
> 
> I get the following back:
> 
> <xsp:page xmlns:xsp="http://apache.org/xsp"
> xmlns:xsp-session="http://apache.org/xsp/session/2.0" language="java"
> create-session="yes">
> <loginreply>
>   <xsp-session:set-attribute
> name="username">krams@krims.ch</xsp-session:set-attribute>
>   <xsp-session:set-max-inactive-interval interval="500" />
>   <status>ok</status>
>   <sessionid><xsp-session:get-id /></sessionid>
>   <username><xsp-session:get-attribute name="username" /></username>
> </loginreply>
> </xsp:page>
> 
> which is perfectly ok.
> 
> but now how do I tell cocoon that it processes the xsp and the
xsp-session
> stuff? as I understood I cannot use a second generator.
> do I have to create some kind of logicsheet? if yes, how should it
look
> like?

See http://localhost:8080/cocoon/sub/xsp-dynamic, and its sitemap.

You must also realize that this approach you chose is slow, or *very*
slow (depends on your pockets, of course). Two-line action will do the
same in almost no time.


Vadim



> kind regards
> 
> daniel



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