Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

cocoon xsl problem

Status
Not open for further replies.

developerinlondon

Programmer
Jan 11, 2003
196
GB
I am trying to run the following sample from the cocoon tutorial but it doesnt seem to be working:

greeting.xml
Code:
<?xml version="1.0"?>

<xsp:page xmlns:xsp="[URL unfurl="true"]http://apache.org/xsp">[/URL]

        <xsp:logic>
                //this could be arbitrarily complex Java code, JDBC queries, etc.
                String msg = "Hello, World!";
        </xsp:logic>

        <greeting>
                <xsp:expr>msg</xsp:expr>
        </greeting>

</xsp:page>

greeting.xsl
Code:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] version="1.0">

<xsl:template match="/">
        <html>
                <body>
        hi
                        <h1>
                                <xsl:value-of select="greeting"/>
                        </h1>
                </body>
        </html>
</xsl:template>

</xsl:stylesheet>

I am using cocoon 2.1.7 on tomcat 5.8 as a servlet. I created my own sample directory in the "samples" directory. My sitemap.xmap file looks like this:
sitemap.xmap:
Code:
<?xml version="1.0"?>

<!-- CVS $Id: sitemap.xmap 30938 2004-07-29 19:08:16Z vgritsenko $ -->

<map:sitemap xmlns:map="[URL unfurl="true"]http://apache.org/cocoon/sitemap/1.0">[/URL]

  <map:pipelines>

    <map:pipeline>
        
      <map:match pattern="greeting">
       <map:generate src="greeting.xml"/>
       <map:transform src="greeting.xsl"/>
      <map:serialize/>
      </map:match>

      <map:match pattern="request.xml">
       <map:generate src="request.xml"/>
      <map:serialize/>
      </map:match>


     </map:pipeline>                

  </map:pipelines>

</map:sitemap>

When I run this, I can only see the 'hi' but not the xsl variable.
anyone has any ideas what I might be doing wrong?

thanks

nayeem
 
ok found the problem. We need to tell cocoon to process it as a serverpage by adding type="serverpages" in the map:generate tag.
eg:
sitemap.xmap
Code:
      <map:match pattern="greeting">
       <map:generate type="serverpages" src="greeting.xml"/>
       <map:transform src="greeting.xsl"/>
      <map:serialize/>
      </map:match>

      <map:match pattern="request.xml">
       <map:generate type="serverpages" src="request.xml"/>
      <map:serialize/>
      </map:match>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top