Simone,

this is very easy to do, and Cocoon provides many different ways you can do
it.

Here's a simple example using only XML and XSLT:

index.xml:
   <?xml version="1.0"?>

   <?cocoon-process type="xslt"?>
   <?xml-stylesheet type="text/xsl" href="index.xsl"?>

   <items>
     <item>one</item>
     <item>two</item>
     <item>three</item>
   </items>

index.xsl:
   <?xml version="1.0"?>
   <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">

   <xsl:param name="item-number"/>

   <xsl:template match="/items">
     <html>
       <xsl:apply-templates/>
     </html>
   </xsl:template>

   <xsl:template match="item[position() = $item-number]">
     Current item: <xsl:value-of select="."/>
     <br/>
     <a>
       <xsl:attribute name="href">
         index.xml?item-number=<xsl:value-of select="$item-number+1"/>
       </xsl:attribute>
       Next
     </a>
   </xsl:template>

   <xsl:template match="item[position() = 1 and not($item-number)]">
     Current item: <xsl:value-of select="."/>
     <br/>
     <a href="index.xml?item-number=2">Next</a>
   </xsl:template>

   <xsl:template match="item" priority="-1"/>

   </xsl:stylesheet>


The reason this works is because Cocoon has nicely made it possible for you
to get query parameters in your XSLT stylesheet just by declaring an
<xsl:param> with the same name.  So, the link we create in the stylesheet
uses a query parameter (?item-number=n) and we pick it up with <xsl:param
name="item-number"/>.

There are many more complex approaches you can try, particularly if you get
into XSP, where you have the whole range of Java and servlet programming
available to you.

-Christopher




Please respond to [EMAIL PROTECTED]

To:   <[EMAIL PROTECTED]>
cc:

Subject:  generate dinamic page from a single index.xml

Hi....
My prior mail was been quite generic. The question  is about the
possibility of create dynamically web page starting from a  single
index.xml page and translate with cocoon and  XSLT. Following the links on
index.xml displayed on browser  the will load a new page that came from
index.xml new  rapresentation.

Is there some suggestion or can be implemented an  equivalent architecture?

Thank for all in advace.
Simone







---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>

To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>

Reply via email to