Enke Michael wrote:
> 
> Hi.
> I had the problem that I have to receive rows from a table
> where the number of columns is variable (because the query is
> variabe). For this reason it is useful to have the element names
> the same for each column.
> I introduced the "tag-name" attribute in esql:get-columns.
> 
> E.g. <esql:get-columns tag-name="column"/> will result in
> <column>
>  col1
> </column>
> <column>
>  col2
> </column>
> ...
> 
> ( Remark: the tag-case applies after this too.
>   <esql:get-columns tag-name="column" tag-case="upper"/>
>   results in <COLUMN>col1</COLUMN>... )
> 
> Could a commiter commit this please?
> One question: If I get the dev-snapshot, which version do I get?
> 2.0 or 2.1?
> 
> Regards,
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]

--- esql.xsl.orig       Mon Sep  3 21:38:36 2001
+++ esql.xsl    Tue Sep  4 09:18:41 2001
@@ -705,23 +705,33 @@
   </xsp:content>
 </xsl:template>
 
-<xspdoc:desc>results in a set of elements whose names are the names of the columns. 
the elements each have one text child, whose value is the value of the column 
interpreted as a string. No special formatting is allowed here. If you want to mess 
around with the names of the elements or the value of the text field, use the 
type-specific get methods and write out the result fragment yourself.</xspdoc:desc>
+<xspdoc:desc>results in a set of elements whose names are the names of the columns or 
+tag-name if given . the elements each have one text child, whose value is the value 
+of the column interpreted as a string. No special formatting is allowed here. If you 
+want to mess around with the names of the elements or the value of the text field, 
+use the type-specific get methods and write out the result fragment 
+yourself.</xspdoc:desc>
 <xsl:template match="esql:row-results//esql:get-columns">
   <xsl:variable name="tagcase"><xsl:value-of select="@tag-case"/></xsl:variable>
+  <xsl:variable name="tagname"><xsl:value-of select="@tag-name"/></xsl:variable>
   <xsl:choose>
     <xsl:when test="$environment = 'cocoon1'">
       <xsp:logic>
         for (int _esql_i=1; _esql_i &lt;= 
_esql_query.resultset_metadata.getColumnCount(); _esql_i++) {
+          String tag-name =
+            <xsl:choose>
+              <xsl:when test="$tagname">
+                "<xsl:value-of select='@tag-name'/>"
+              </xsl:when>
+              <xsl:otherwise>
+                _esql_query.resultset_metadata.getColumnName(_esql_i)
+              </xsl:otherwise>
+            </xsl:choose>;
           Node _esql_node = document.createElement(
             <xsl:choose>
               <xsl:when test="$tagcase='lower'">
-                _esql_query.resultset_metadata.getColumnName(_esql_i).toLowerCase()
+                tag-name.toLowerCase()
               </xsl:when>
               <xsl:when test="$tagcase='upper'">
-                _esql_query.resultset_metadata.getColumnName(_esql_i).toUpperCase()
+                tag-name.toUpperCase()
               </xsl:when>
               <xsl:otherwise>
-                _esql_query.resultset_metadata.getColumnName(_esql_i)
+                tag-name
               </xsl:otherwise>
             </xsl:choose>
           );
@@ -738,7 +748,14 @@
     <xsl:when test="$environment = 'cocoon2'">
       <xsp:logic>
         for (int _esql_i = 1; _esql_i &lt;= 
_esql_query.resultset_metadata.getColumnCount(); _esql_i++) {
-          String _esql_tagname = 
_esql_query.resultset_metadata.getColumnName(_esql_i);
+          <xsl:choose>
+           <xsl:when test="@tag-name">
+            String _esql_tagname = "<xsl:value-of select='@tag-name'/>";
+           </xsl:when>
+           <xsl:otherwise>
+            String _esql_tagname = 
+_esql_query.resultset_metadata.getColumnName(_esql_i);
+           </xsl:otherwise>
+          </xsl:choose>
           <xsp:element>
             <xsp:param name="name">
               <xsl:choose>

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

Reply via email to