cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ba...@locus.apache.org
Subject cvs commit: xml-cocoon/src/org/apache/cocoon/processor/xsp/library/sql XSPSQLLibrary.java
Date Tue, 16 May 2000 20:01:07 GMT
balld       00/05/16 13:01:06

  Modified:    src/org/apache/cocoon/processor/xsp/library/java sql.xsl
               src/org/apache/cocoon/processor/xsp/library/sql
                        XSPSQLLibrary.java
  Log:
  fixed bug when missing doc-element
  
  Revision  Changes    Path
  1.13      +5 -7      xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/sql.xsl
  
  Index: sql.xsl
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/java/sql.xsl,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- sql.xsl	2000/05/09 19:15:35	1.12
  +++ sql.xsl	2000/05/16 20:01:04	1.13
  @@ -179,10 +179,7 @@
   			column_formats.put(name,format);
   		}
   		</xsl:for-each>
  -
  -	<xsp:content>
  -	<xsp:expr>
  -		XSPSQLLibrary.processQuery(
  +		Element result_elements[] = XSPSQLLibrary.processQuery(
   			document,
   			String.valueOf(<xsl:copy-of select="$driver"/>),
   			String.valueOf(<xsl:copy-of select="$dburl"/>),
  @@ -203,9 +200,10 @@
   			String.valueOf(<xsl:copy-of select="$update-rows-attribute"/>),
   			String.valueOf(<xsl:copy-of select="$namespace"/>),
   			String.valueOf(<xsl:copy-of select="$query"/>),
  -			column_formats)
  -	</xsp:expr>
  -	</xsp:content>
  +			column_formats);
  +		for (int i=0; i&lt;result_elements.length; i++) {
  +			<xsp:content><xsp:expr>result_elements[i]</xsp:expr></xsp:content>
  +		}
   	}
   	</xsp:logic>
   </xsl:template>
  
  
  
  1.7       +20 -8     xml-cocoon/src/org/apache/cocoon/processor/xsp/library/sql/XSPSQLLibrary.java
  
  Index: XSPSQLLibrary.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/processor/xsp/library/sql/XSPSQLLibrary.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XSPSQLLibrary.java	2000/05/16 18:36:10	1.6
  +++ XSPSQLLibrary.java	2000/05/16 20:01:06	1.7
  @@ -60,12 +60,12 @@
    * A processor that performs SQL database queries.
    *
    * @author <a href="mailto:balld@webslingerZ.com">Donald Ball</a>
  - * @version $Revision: 1.6 $ $Date: 2000/05/16 18:36:10 $
  + * @version $Revision: 1.7 $ $Date: 2000/05/16 20:01:06 $
    */
   
   public class XSPSQLLibrary {
   
  -    public static Node processQuery(
  +    public static Element[] processQuery(
         Document document,
         String driver,
         String dburl,
  @@ -119,9 +119,9 @@
               results_node = document.createDocumentFragment();
           } else {
               results_element = createElement(document,namespace,doc_element_name);
  +			results_node = results_element;
           }
  -        results_node = results_element;
  -        if (!count_attribute.equals("")) {
  +        if (results_element != null && !count_attribute.equals("")) {
               String count_query = getCountQuery(query);
               if (count_query != null) {
                   rs = st.executeQuery(count_query);
  @@ -131,13 +131,13 @@
                   rs.close();
               }
           }
  -        if (!query_attribute.equals("")) {
  +        if (results_element != null && !query_attribute.equals("")) {
               results_element.setAttribute(query_attribute,URLEncoder.encode(query));
           }
  -        if (!skip_rows_attribute.equals("")) {
  +        if (results_element != null && !skip_rows_attribute.equals("")) {
               results_element.setAttribute(skip_rows_attribute,""+skip_rows);
           }
  -        if (!max_rows_attribute.equals("")) {
  +        if (results_element != null && !max_rows_attribute.equals("")) {
               results_element.setAttribute(max_rows_attribute,""+max_rows);
           }
           if (!st.execute(query)) {
  @@ -220,7 +220,19 @@
               rs.close();
           }
           st.close(); conn.close();
  -        return results_node;
  +		if (results_element != null) {
  +			Element ary[] = new Element[1];
  +			ary[0] = results_element;
  +			return ary;
  +		} else {
  +			NodeList nodes = results_node.getChildNodes();
  +			int length = nodes.getLength();
  +			Element ary[] = new Element[length];
  +			for (int i=0; i<length; i++) {
  +				ary[i] = (Element)nodes.item(i);
  +			}
  +			return ary;
  +		}
       }
   
       protected static Column[] getColumns(ResultSetMetaData md, String tag_case) throws
SQLException {
  
  
  

Mime
View raw message