You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Zaid Al-Timimi <za...@altConsulting.com> on 2002/11/10 17:12:18 UTC

[Q] sql extensions still broken on 2.4.1

Hi,


All was well with J2RE 1.3.1_06 and Xalan 2.4 but broke on J2RE 1.4.x with
the now fixed XPath bug.


Now with the latest Xalan 2.4.1 the transformation works but the SQL
extension does not return any elements. It does not seem to be a JDBC driver
problem as I've tried the same code with JDBC-ODBC and the Northwind
database with the same results:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sql PUBLIC "-//ALTMOBILE//DTD SQL 1.1//EN"
"http://www.altMobile.com/DTD/xalanSQL10.dtd">
<sql jdbc-driver="ORG.as220.tinySQL.dbfFileDriver"
jdbc-datasource="jdbc:dbfFile:./store/db"
system-dtd="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"
public-dtd="-//WAPFORUM//DTD XHTML Mobile 1.0//EN" jdbc-query="select * from
MOVIES" formatParam="LIST" multiple-cards=""/>

There should be 100 or so elements transformed from the database but only
those created via LRE or via <xsl:element> in the XSL are generated to the
output.



My edited config is as follows:


#---- BEGIN writeEnvironmentReport($Revision: 1.14 $): Useful stuff
found: ----

version.DOM.draftlevel=2.0fd

version.JAXP=1.1

version.xerces2=Xerces-J 2.2.0

version.xerces1=not-present

version.xalan2_2=Xalan Java 2.4.1

version.xalan1=not-present

version.ant=not-present

java.version=1.4.1_01

version.DOM=2.0

version.crimson=present-unknown-version

xercesImpl.jar-apparent.version=xercesImpl.jar from xalan-j_2_4_1 from
xerces-2_2

xml-apis.jar-apparent.version=xml-apis.jar from xalan-j_2_4_1,
lotusxsl-j_2_3_4 or lotusxsl-j_2_3_5 from factoryfinder-build of xml-commons
RIVERCOURT1

version.SAX=2.0

version.xalan2x=Xalan Java 2.4.1

#----- END writeEnvironmentReport: Useful properties found: -----

# YAHOO! Your environment seems to be OK.



********************************


Here is the XSL but the same errors occur using the sample from the web site
with different JDBC drivers:


<?xml version="1.0"?>
 <xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="1.0"
  xmlns:sql="http://xml.apache.org/xalan/sql"
  extension-element-prefixes="sql"
 >
  <xsl:output method="xml"
    doctype-system="http://www.altMobile.com/DTD/xalanSQL10.dtd"
    doctype-public="-//ALTMOBILE//DTD SQL 1.1//EN"
    indent="yes"/>

  <xsl:param name="driver" select="'ORG.as220.tinySQL.dbfFileDriver'"/>
  <xsl:param name="datasource" select="'jdbc:dbfFile:./store/db'"/>
  <xsl:param name="query" select="'select * from MOVIES'"/>


  <xsl:param
   name="generated-system-dtd"
   select="'http://www.wapforum.org/DTD/xhtml-mobile10.dtd'"/>
  <xsl:param
   name="generated-public-dtd"
   select="'-//WAPFORUM//DTD XHTML Mobile 1.0//EN'"/>

  <xsl:param name="formatParam" select="'LIST'"/>

  <xsl:param name="multiple-cards"/>

  <xsl:template match="/">
   <xsl:variable name="db" select="sql:new($driver, $datasource)"/>
   <xsl:variable name="table" select='sql:query($db, $query)'/>
   <xsl:variable name="sqlDocElementVar" select="$table/sql"/>
   <xsl:element name="sql">
    <xsl:attribute name="jdbc-driver">
     <xsl:value-of select="$driver"/>
    </xsl:attribute>
    <xsl:attribute name="jdbc-datasource">
     <xsl:value-of select="$datasource"/>
    </xsl:attribute>
    <xsl:attribute name="system-dtd">
     <xsl:value-of select="$generated-system-dtd"/>
    </xsl:attribute>
    <xsl:attribute name="public-dtd">
     <xsl:value-of select="$generated-public-dtd"/>
    </xsl:attribute>
    <xsl:attribute name="jdbc-query">
     <xsl:value-of select="$query"/>
    </xsl:attribute>
    <xsl:attribute name="formatParam">
     <xsl:value-of select="$formatParam"/>
    </xsl:attribute>
    <xsl:attribute name="multiple-cards">
     <xsl:value-of select="$multiple-cards"/>
    </xsl:attribute>

<!-- the relevant code is here -->
    <xsl:copy-of select="$table/sql/metadata" />
    <xsl:copy-of select="$table/sql/row-set" />
   </xsl:element>

   <xsl:value-of select="sql:close($db)"/>
  </xsl:template>
 </xsl:stylesheet>




thanks--

Zaid


Re: [Q] sql extensions still broken on 2.4.1

Posted by John Gentilin <ge...@eyecatching.com>.
Ziad,

The SQL Extension implements a mechanism called streaming mode.
In streaming mode, there is only one active row from the DB  the
previous data rows are shifted into the big bit bucket as you traverse
the document, so... the statement
   <xsl:variable name="sqlDocElementVar" select="$table/sql"/>

Copies the rows from the query into the variable sqlDocElementVar
and also exhausts the data returned from query.

Streaming is only concerned with the /sql/row-set data, not the metadata
since there is only once copy anyway. Once the copy is complete, the
SQL ResultSet will be exhausted and there will not be any rows left but
the metadata section will still be available.

Your query data is still intact in the variable although this is unadvisable.
When you copied the raw sql node into the variable, all the data gets
expanded.  Another memory savings technique implement in the SQL
extension is to mirror the Metadata from the metadata section for each
row, the data is not copied. You variable assignment will actually copy
the complete SQL document into the variable making a separate copy
of the Metadata items for each row. Since each column has ~ 10 attributes,
the memory consumption for  the variable will be substantial.

If you want to do what you code seems to be doing, I would suggest turning
streaming mode off  by calling the disableStreamingMode() method, this will
allow you to traverse the variable more than once without copying the data.

Regards
John G

Zaid Al-Timimi wrote:

> Hi,
>
> All was well with J2RE 1.3.1_06 and Xalan 2.4 but broke on J2RE 1.4.x with
> the now fixed XPath bug.
>
> Now with the latest Xalan 2.4.1 the transformation works but the SQL
> extension does not return any elements. It does not seem to be a JDBC driver
> problem as I've tried the same code with JDBC-ODBC and the Northwind
> database with the same results:
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE sql PUBLIC "-//ALTMOBILE//DTD SQL 1.1//EN"
> "http://www.altMobile.com/DTD/xalanSQL10.dtd">
> <sql jdbc-driver="ORG.as220.tinySQL.dbfFileDriver"
> jdbc-datasource="jdbc:dbfFile:./store/db"
> system-dtd="http://www.wapforum.org/DTD/xhtml-mobile10.dtd"
> public-dtd="-//WAPFORUM//DTD XHTML Mobile 1.0//EN" jdbc-query="select * from
> MOVIES" formatParam="LIST" multiple-cards=""/>
>
> There should be 100 or so elements transformed from the database but only
> those created via LRE or via <xsl:element> in the XSL are generated to the
> output.
>
> My edited config is as follows:
>
> #---- BEGIN writeEnvironmentReport($Revision: 1.14 $): Useful stuff
> found: ----
>
> version.DOM.draftlevel=2.0fd
>
> version.JAXP=1.1
>
> version.xerces2=Xerces-J 2.2.0
>
> version.xerces1=not-present
>
> version.xalan2_2=Xalan Java 2.4.1
>
> version.xalan1=not-present
>
> version.ant=not-present
>
> java.version=1.4.1_01
>
> version.DOM=2.0
>
> version.crimson=present-unknown-version
>
> xercesImpl.jar-apparent.version=xercesImpl.jar from xalan-j_2_4_1 from
> xerces-2_2
>
> xml-apis.jar-apparent.version=xml-apis.jar from xalan-j_2_4_1,
> lotusxsl-j_2_3_4 or lotusxsl-j_2_3_5 from factoryfinder-build of xml-commons
> RIVERCOURT1
>
> version.SAX=2.0
>
> version.xalan2x=Xalan Java 2.4.1
>
> #----- END writeEnvironmentReport: Useful properties found: -----
>
> # YAHOO! Your environment seems to be OK.
>
> ********************************
>
> Here is the XSL but the same errors occur using the sample from the web site
> with different JDBC drivers:
>
> <?xml version="1.0"?>
>  <xsl:stylesheet
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
>   version="1.0"
>   xmlns:sql="http://xml.apache.org/xalan/sql"
>   extension-element-prefixes="sql"
>  >
>   <xsl:output method="xml"
>     doctype-system="http://www.altMobile.com/DTD/xalanSQL10.dtd"
>     doctype-public="-//ALTMOBILE//DTD SQL 1.1//EN"
>     indent="yes"/>
>
>   <xsl:param name="driver" select="'ORG.as220.tinySQL.dbfFileDriver'"/>
>   <xsl:param name="datasource" select="'jdbc:dbfFile:./store/db'"/>
>   <xsl:param name="query" select="'select * from MOVIES'"/>
>
>   <xsl:param
>    name="generated-system-dtd"
>    select="'http://www.wapforum.org/DTD/xhtml-mobile10.dtd'"/>
>   <xsl:param
>    name="generated-public-dtd"
>    select="'-//WAPFORUM//DTD XHTML Mobile 1.0//EN'"/>
>
>   <xsl:param name="formatParam" select="'LIST'"/>
>
>   <xsl:param name="multiple-cards"/>
>
>   <xsl:template match="/">
>    <xsl:variable name="db" select="sql:new($driver, $datasource)"/>
>    <xsl:variable name="table" select='sql:query($db, $query)'/>
>    <xsl:variable name="sqlDocElementVar" select="$table/sql"/>
>    <xsl:element name="sql">
>     <xsl:attribute name="jdbc-driver">
>      <xsl:value-of select="$driver"/>
>     </xsl:attribute>
>     <xsl:attribute name="jdbc-datasource">
>      <xsl:value-of select="$datasource"/>
>     </xsl:attribute>
>     <xsl:attribute name="system-dtd">
>      <xsl:value-of select="$generated-system-dtd"/>
>     </xsl:attribute>
>     <xsl:attribute name="public-dtd">
>      <xsl:value-of select="$generated-public-dtd"/>
>     </xsl:attribute>
>     <xsl:attribute name="jdbc-query">
>      <xsl:value-of select="$query"/>
>     </xsl:attribute>
>     <xsl:attribute name="formatParam">
>      <xsl:value-of select="$formatParam"/>
>     </xsl:attribute>
>     <xsl:attribute name="multiple-cards">
>      <xsl:value-of select="$multiple-cards"/>
>     </xsl:attribute>
>
> <!-- the relevant code is here -->
>     <xsl:copy-of select="$table/sql/metadata" />
>     <xsl:copy-of select="$table/sql/row-set" />
>    </xsl:element>
>
>    <xsl:value-of select="sql:close($db)"/>
>   </xsl:template>
>  </xsl:stylesheet>
>
> thanks--
>
> Zaid

--
--------------------------------------
John Gentilin
Eye Catching Solutions Inc.
18314 Carlwyn Drive
Castro Valley CA 94546

    Contact Info
gentijo@eyecatching.com
Ca Office 1-510-881-4821
NJ Office 1-732-422-4917