You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by dl...@apache.org on 2001/01/09 18:25:31 UTC

cvs commit: xml-xalan/java/samples/extensions 6-sqllib-instantdb.xsl

dleslie     01/01/09 09:25:31

  Added:       java/samples/extensions 6-sqllib-instantdb.xsl
  Log:
  SQL libray sample witnh InstantDB sample.
  
  Revision  Changes    Path
  1.1                  xml-xalan/java/samples/extensions/6-sqllib-instantdb.xsl
  
  Index: 6-sqllib-instantdb.xsl
  ===================================================================
  <?xml version="1.0"?>
  <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                  version="1.0"
                  xmlns:sql="org.apache.xalan.lib.sql.XConnection"
                  extension-element-prefixes="sql">
    <xsl:output method="html" indent="yes"/>
    <xsl:param name="query" select="'SELECT * FROM import1'"/>
   
    <xsl:template match="/">
      <!-- 1. Make the connection -->
      <xsl:variable name="products"
                    select="sql:new('org.enhydra.instantdb.jdbc.idbDriver',
                                  'jdbc:idb:./instantdb/sample.prp')"/>
      <HTML>
        <HEAD>
        </HEAD>
        <BODY>
          <TABLE border="1">
          <!--2. Execute the query -->
          <xsl:variable name="table" select='sql:query($products, $query)'/>
            <TR>
            <!-- Get column-label attribute from each column-header-->
            <xsl:for-each select="$table/row-set/column-header">
              <TH><xsl:value-of select="@column-label"/></TH>
            </xsl:for-each>
            </TR>
            <xsl:apply-templates select="$table/row-set/row"/>
            <xsl:text>&#10;</xsl:text>
          </TABLE>
        </BODY>
      </HTML> 
      <!-- 3. Close the connection -->
      <xsl:value-of select="sql:close($products)"/>
    </xsl:template>
  
    <xsl:template match="row">
          <TR>
            <xsl:apply-templates select="col"/>
          </TR>
    </xsl:template>
  
    <xsl:template match="col">
      <TD>
        <!-- Here is the column data -->
        <xsl:value-of select="text()"/>
      </TD>
    </xsl:template>
  
  </xsl:stylesheet>