4
* Licensed to the Apache Software Foundation (ASF) under one
5
* or more contributor license agreements. See the NOTICE file
6
* distributed with this work for additional information
7
* regarding copyright ownership. The ASF licenses this file
8
* to you under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
21
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
25
xmlns:sql="org.apache.xalan.lib.sql.XConnection"
27
extension-element-prefixes="sql">
31
<xsl:output method="html" indent="yes"/>
35
<xsl:param name="driver" select="'org.apache.derby.jdbc.EmbeddedDriver'"/>
37
<xsl:param name="datasource" select="'jdbc:derby:sampleDB'"/>
39
<xsl:param name="query" select="'SELECT * FROM import1'"/>
43
<xsl:template match="/">
45
<xsl:variable name="db" select="sql:new()"/>
49
<!-- Connect to the database with minimal error detection -->
51
<xsl:if test="not(sql:connect($db, $driver, $datasource))" >
53
<xsl:message>Error Connecting to the Database</xsl:message>
55
<xsl:copy-of select="sql:getError($db)/ext-error" />
67
<TITLE>List of products</TITLE>
75
<!-- Turn off Streaming -->
77
<xsl:value-of select="sql:setFeature($db, 'streaming', 'false')" />
81
<xsl:variable name="table" select='sql:query($db, $query)'/>
87
Let's include Error Checking, the error is actually stored
89
in the connection since $table will be either data or null
95
<xsl:if test="not($table)" >
97
<xsl:message>Error in Query</xsl:message>
99
<xsl:copy-of select="sql:getError($db)/ext-error" />
113
<xsl:for-each select="$table/sql/metadata/column-header">
115
<TH><xsl:value-of select="@column-label"/></TH>
121
<xsl:apply-templates select="$table/sql/row-set"/>
131
<xsl:for-each select="$table/sql/metadata/column-header">
133
<xsl:variable name="column" select="@column-label" />
139
<TD><TH><xsl:value-of select="$column"/></TH></TD>
143
select="$table/sql/row-set/row/col[@column-label=$column]" />
161
<xsl:value-of select="sql:close($db)"/>
167
<xsl:template match="row">
169
<TR><xsl:apply-templates select="col"/></TR>
175
<xsl:template match="col">
177
<TD><xsl:value-of select="text()"/></TD>
b'\\ No newline at end of file'