Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 79242 invoked by uid 500); 11 Jul 2001 12:31:11 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 78975 invoked from network); 11 Jul 2001 12:31:04 -0000 Date: Wed, 11 Jul 2001 14:28:31 +0200 From: Christian Haul To: cocoon-dev@xml.apache.org Subject: [ESQL/PATCH] proposed changes Message-ID: <20010711142831.M13821@bremen.dvs1.informatik.tu-darmstadt.de> Reply-To: haul@informatik.tu-darmstadt.de Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="GRPZ8SYKNexpdSJ7" Content-Disposition: inline User-Agent: Mutt/1.2.5i Organization: Databases and Distributed Systems Group, Darmstadt University of Technology X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N --GRPZ8SYKNexpdSJ7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Team, I'm currently considering ORDBMS support in esql, well, actually, I do have a version here that does it for C2. Davanum asked me to post any patches to esql.xsl to this list before applying them. So please comment the attached diff. This mail is largely based on my posting from jul-04 on ordbms support for esql with few modifications and comments what is already in place. The simplest ORDBMS support would be to allow the user to get an object from the query and to leave it to her/him how to deal with it. (done) In addition one could extend get-columns to extract advanced datatypes as well. Over here on Informix IUS 9.21 these are mostly of java.sql.Types.STRUCT for row types and java.sql.Types.OTHER for everything else like sets, lists, bags. One way to determine the correct type would be to try to cast the object to an appropriate interface, say java.util.Set. (done -- C2 only) How should the structure of an attribute be represented? Nesting alone wouldn't do since it wouldn't be possible to distinguish sets from structs. So we should introduce something like "sql-list", "sql-row", "sql-set", plus some "sql-item" elements to capture e.g. the list members. So far I didn't find a way e.g. to name the components of a struct. (done -- C2 only) Another issue arises: encoding. "First class" attributes can be read through getBytes() and converted afterwards. But nested attributes only offer a toString() method, right? Would it be right to disable the encoding parameter on nested attributes? (currently no encoding for complex attributes) Another feature could be, to manipulate the type mapping table for a jdbc connection and allow to map advanced or user defined types to map to a user provided java class. Jdbc drivers sometimes come with a utility to create such a class from a db schema. (not done -- should this be done? should this be done in cocoon.xconf per connection pool?) Other features I'd like to see in esql: &c. "swallow" nested text which is not what users expect (see cocoon-users list). Therefore it would be nice if the text would be automtically enclosed in . (done -- example query is "select count(*) from mytable": Currently rows are present. ) Supplying column names / numbers from a XSP variable (esql differs from other taglibs in that it doesn't use the "1" notation, instead it uses "". I would like to change that.) (done, you can now i ) Offer some direct paths to the esql code, like "get-metadata", "get-column-type", "get-object", or even "get-resultset" (done) Make "get-xml" more powerful so that the db needs only to store fragments of an xml document. Currently, only a root element without any attributes is allowed here. Thus it is not possible e.g. to specify a namespace for the fragment. (not done yet -- why doesn't it inherit the namespaces from the original xsp? Is there a way to figure them out?) BTW since it is possible to include other logicsheets, would it be wise to put all utility tags (copy-all, get-nested-content, get-parameter and the like) to a common logicsheet so that they could easily be used by new logicsheets? Chris. -- C h r i s t i a n H a u l haul@informatik.tu-darmstadt.de fingerprint: 99B0 1D9D 7919 644A 4837 7D73 FEF9 6856 335A 9E08 --GRPZ8SYKNexpdSJ7 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="esql.diff" Index: src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl =================================================================== RCS file: /home/cvs/xml-cocoon2/src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl,v retrieving revision 1.11 diff -u -r1.11 esql.xsl --- src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl 2001/07/10 14:04:15 1.11 +++ src/org/apache/cocoon/components/language/markup/xsp/java/esql.xsl 2001/07/11 11:18:07 @@ -71,6 +71,8 @@ http://www.apache.org/1999/XSP/Core http://apache.org/xsp +esql + @@ -159,6 +161,44 @@ + + + + + false + + + + + + + "" + + + + + + + + + + + + [Logicsheet processor] +Parameter '' missing in dynamic tag <> + + + + "" + + + + + + + + @@ -177,6 +217,12 @@ java.io.PrintWriter java.io.BufferedInputStream java.io.InputStream + java.util.Set + java.util.List + java.util.Iterator + java.util.ListIterator + java.sql.Struct + java.sql.Types org.apache.cocoon.components.language.markup.xsp.XSPUtil @@ -268,6 +314,44 @@ return new String(buffer); } + + + + + + protected void _esql_printObject ( Object obj, AttributesImpl xspAttr) throws SAXException + { + try { + ListIterator j=((List)obj).listIterator(); + + + while (j.hasNext()){ + + j.nextIndex() + this._esql_printObject(j.next(),xspAttr); + + }; + + + } catch (Exception e){ + try { + Iterator j=((Set)obj).iterator(); + + + while (j.hasNext()){ + + this._esql_printObject(j.next(),xspAttr); + + }; + + + } catch (Exception f) { + obj; + } + } + } + + @@ -554,17 +638,23 @@ "?" - + + + - + + + if (_esql_query.position == _esql_query.skip_rows) { - + + + } @@ -576,7 +666,9 @@ while (_esql_query.resultset.next()) { - + + + if (_esql_connection.use_limit_clause == 0 && _esql_query.max_rows != -1 && _esql_query.position - _esql_query.skip_rows == _esql_query.max_rows-1) { _esql_query.position++; break; @@ -584,7 +676,7 @@ _esql_query.position++; } if (_esql_query.resultset.next()) { - + _esql_query.position++; } @@ -593,7 +685,9 @@ - + + + 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. @@ -644,12 +738,35 @@ - - - _esql_i - _esql_query.resultset - - + + switch(_esql_query.resultset.getMetaData().getColumnType(_esql_i)){ + case java.sql.Types.ARRAY: + case java.sql.Types.STRUCT: + + + Object[] _esql_struct = ((Struct) _esql_query.resultset.getObject(_esql_i)).getAttributes(); + for ( int _esql_k=0; _esql_k<_esql_struct.length; _esql_k++){ + this._esql_printObject(_esql_struct[_esql_k],xspAttr); + } + + + break; + + case java.sql.Types.OTHER: // This is what Informix uses for Sets, Bags, Lists + this._esql_printObject(_esql_query.resultset.getObject(_esql_i), xspAttr); + break; + + default: + // standard type + + + + _esql_i + _esql_query.resultset + + + } + } this.characters("\n"); @@ -738,6 +855,16 @@ +returns the current result set + + + + +returns the value of the given column as an object + + .getObject() + + returns the value of the given column as an integer .getInt() @@ -831,6 +958,11 @@ .getMetaData().getColumnCount() +returns the metadata of the resultset. + + .getMetaData() + + returns the position of the current row in the result set _esql_query.position @@ -838,17 +970,22 @@ returns the name of the given column. the column mus tbe specified by number, not name. - .getMetaData().getColumnName() + .getMetaData().getColumnName() returns the label of the given column. the column mus tbe specified by number, not name. - .getMetaData().getColumnLabel() + .getMetaData().getColumnLabel() returns the name of the type of the given column. the column must be specified by number, not name. - .getMetaData().getColumnTypeName() + .getMetaData().getColumnTypeName() + + +returns the type of the given column as int. the column must be specified by number, not name. + + .getMetaData().getColumnType() allows null-column testing. Evaluates to a Java expression, which is true when the referred column contains a null-value for the current resultset row @@ -890,24 +1027,29 @@ used internally to determine which column is the given column. if a column attribute exists and itcvs server: Diffing src/org/apache/cocoon/components/language/programming s value is a number, it is taken to be the column's position. if the value is not a number, it is taken to be the column's name. if a column attribute does not exist, an esql:column element is assumed to exist and to render as a string (after all of the xsp instructions have been evaluated), which is taken to be the column's name. + + + column + true + + - + + + + - - + + - " - - " + - - - - - + + + --GRPZ8SYKNexpdSJ7 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org --GRPZ8SYKNexpdSJ7--