cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Bierenfeld <michael.bierenf...@atmiralis.de>
Subject Q: java loops and tags
Date Tue, 02 Jan 2001 16:21:17 GMT
Hello,

happy new year ! I am having a small problem with xslt and xsp :

the following xsp-sniplet is used to retrieve records out of a database.
These records should be displayed as a select field in html :

The Records are already fetched and stored in a vector.

<xsl:template match="select">

   <select>      <!-- To be transformed to the html-tag "select" later
on -->

   <xsp:logic>

   Vector records = database.fetchAll ();   // Whatever

   for (int i=0; i &lt; records.size (); i++) {

	Record record = (Record) record.elementAt (i);

	<option>   <!-- to be tranformed i times to the html-tag "option" -->

           <xsp:attribute name="value">

		<xsp:expr>record.getField ("whatever")</xsp:expr>

	   </xsp:attribute>

	   <xsp:content>

		<xsp:expr>record.getField ("whatever2")</xsp:expr>

	   </xsp:content>

	</option>            <!-- THIS ONE IS MISSING -->

   }

   </xsp:logic>

   <xsl:copy-of select="@*">

   </select>

</xsl:template>

"<select>" and "option" are further more handled by :

<xsl:template match="select">

  <select size="{@size}>
	<xsl:apply-templates/>
  </select>

</xsl:template>

<xsl:template match="option">

  <option value="{@value}>
	<xsl:apply-templates/>
  </option>

</xsl:template>



Its working somewhat correct. The result with the additional templates
is

<select>
   <option value="1">Description 1
   <option value="2"> and so on...
   ......
</select>


** But the closing </option> tag is missing. I think I am on the wrong
way somewhat.

Kind regards

Michael

Mime
View raw message