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/05/01 23:11:38 UTC
cvs commit: xml-xalan/java/samples/extensions/sql/show-error dbtest.xsl
dleslie 01/05/01 14:11:38
Modified: java/samples/extensions/sql/ext-connection
ExternalConnection.java
java/samples/extensions/sql/pquery dbtest.xsl
java/samples/extensions/sql/show-error dbtest.xsl
Log:
Updates to sql/extensions samples: removed xml source
document where not required, and modified ExternalConnection.java
to use a "dummy" XML source.
Revision Changes Path
1.2 +13 -5 xml-xalan/java/samples/extensions/sql/ext-connection/ExternalConnection.java
Index: ExternalConnection.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/extensions/sql/ext-connection/ExternalConnection.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ExternalConnection.java 2001/04/19 04:16:13 1.1
+++ ExternalConnection.java 2001/05/01 21:11:35 1.2
@@ -67,6 +67,7 @@
// Imported java classes
+import java.io.StringReader;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -110,13 +111,20 @@
Transformer transformer = tFactory.newTransformer(
new StreamSource("dbtest.xsl"));
- // Use the Transformer to apply the associated Templates object to an XML document
- // (foo.xml) and write the output to a file (foo.out).
+ // For this transformation, all the required information is in the stylesheet, so generate
+ // a minimal XML source document for the input.
+ // Note: the command-line processor (org.apache.xalan.xslt.Process) uses this strategy when
+ // the user does not provide an -IN parameter.
+ StringReader reader =
+ new StringReader("<?xml version=\"1.0\"?> <doc/>");
+
+ // Use the Transformer to apply the associated Templates object to an XML document
+ // and write the output to a file.
transformer.transform(
- new StreamSource("dbtest.xml"),
- new StreamResult(new FileOutputStream("dbtest.out")));
+ new StreamSource(reader),
+ new StreamResult(new FileOutputStream("dbtest-out.html")));
- System.out.println("************* The result is in dbtest.out *************");
+ System.out.println("************* The result is in dbtest-out.html *************");
cp.disablePool();
}
1.2 +49 -50 xml-xalan/java/samples/extensions/sql/pquery/dbtest.xsl
Index: dbtest.xsl
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/extensions/sql/pquery/dbtest.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dbtest.xsl 2001/04/19 04:16:14 1.1
+++ dbtest.xsl 2001/05/01 21:11:36 1.2
@@ -1,51 +1,50 @@
-<?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"/>
-
-<!-- Build a Parameter Type Query -->
-<xsl:param name="q1" select="'SELECT * FROM import1 where ProductID = ?'"/>
-
-<!-- Build a CSV list of parameter types -->
-<xsl:param name="q1type" select="int" />
-
-<!-- Pull out connection information from the Document Source -->
-<xsl:param name="cinfo" select="//DBINFO" />
-
-<xsl:template match="/">
- <xsl:variable name="db" select="sql:new($cinfo)"/>
-
- <HTML>
- <HEAD>
- <TITLE>List of products</TITLE>
- </HEAD>
- <BODY>
- <TABLE border="1">
- <xsl:variable name="qparam" select="//QUERY"/>
- <xsl:value-of select="sql:addParameterFromElement($db, $qparam)"/>
-
- <xsl:variable name="table" select='sql:pquery($db, $q1, $q1type )'/>
- <TR>
- <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"/>
- </TABLE>
- </BODY>
- </HTML>
- <xsl:value-of select="sql:close($db)"/>
-</xsl:template>
-
-<xsl:template match="row">
- <TR><xsl:apply-templates select="col"/></TR>
-</xsl:template>
-
-<xsl:template match="col">
- <TD><xsl:value-of select="text()"/></TD>
-</xsl:template>
-
+<?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"/>
+
+<!-- Build a Parameter Type Query -->
+<xsl:param name="q1" select="'SELECT * FROM import1 where ProductID = ?'"/>
+
+<!-- Build a CSV list of parameter types -->
+<xsl:param name="q1type" select="int" />
+
+<!-- Pull out connection information from the Document Source -->
+<xsl:param name="cinfo" select="//DBINFO" />
+
+<xsl:template match="/">
+ <xsl:variable name="db" select="sql:new($cinfo)"/>
+ <HTML>
+ <HEAD>
+ <TITLE>List of products</TITLE>
+ </HEAD>
+ <BODY>
+ <TABLE border="1">
+ <xsl:variable name="qparam" select="//QUERY"/>
+ <xsl:value-of select="sql:addParameterFromElement($db, $qparam)"/>
+ <xsl:variable name="table" select='sql:pquery($db, $q1, $q1type )'/>
+ <TR>
+ <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"/>
+ </TABLE>
+ </BODY>
+ </HTML>
+ <xsl:value-of select="sql:close($db)"/>
+</xsl:template>
+
+<xsl:template match="row">
+ <TR><xsl:apply-templates select="col"/></TR>
+</xsl:template>
+
+<xsl:template match="col">
+ <TD><xsl:value-of select="text()"/></TD>
+</xsl:template>
+
</xsl:stylesheet>
1.2 +53 -67 xml-xalan/java/samples/extensions/sql/show-error/dbtest.xsl
Index: dbtest.xsl
===================================================================
RCS file: /home/cvs/xml-xalan/java/samples/extensions/sql/show-error/dbtest.xsl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- dbtest.xsl 2001/04/19 04:16:14 1.1
+++ dbtest.xsl 2001/05/01 21:11:37 1.2
@@ -1,68 +1,54 @@
-<?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="driver" select="'org.enhydra.instantdb.jdbc.idbDriver'"/>
-<xsl:param name="datasource" select="'jdbc:idb:../../instantdb/sample.prp'"/>
-
-<!-- Build an invalid query -->
-<xsl:param name="query" select="'SELECT * FROM import1x'"/>
-
- <xsl:template match="/">
- <!-- 1. Make the connection -->
- <xsl:variable name="db" select="sql:new($driver, $datasource)"/>
-
- <!--2. Execute the query -->
- <xsl:variable name="table" select='sql:query($db, $query)'/>
-
- <xsl:apply-templates select="$table/row-set" />
- <xsl:apply-templates select="$table/ext-error" />
-
- <!-- 3. Close the connection -->
- <xsl:value-of select="sql:close($db)"/>
-
- </xsl:template>
-
-
-
-<xsl:template match="row-set">
-
- <HTML>
- <HEAD>
- <TITLE>List of products</TITLE>
- </HEAD>
- <BODY>
- <TABLE border="1">
- <TR>
- <xsl:for-each select="/row-set/column-header">
- <TH><xsl:value-of select="@column-label"/></TH>
- </xsl:for-each>
- </TR>
- <xsl:apply-templates select="/row-set/row"/>
- </TABLE>
- </BODY>
- </HTML>
-</xsl:template>
-
-<xsl:template match="row">
- <TR><xsl:apply-templates select="col"/></TR>
-</xsl:template>
-
-<xsl:template match="col">
- <TD><xsl:value-of select="text()"/></TD>
-</xsl:template>
-
-
-<xsl:template match="/ext-error">
- <xsl:text>Woops, an error occured: </xsl:text>
- <xsl:apply-templates select="/ext-error/exception-info/message" />
- <xsl:text> -- SQL Error Code: </xsl:text>
- <xsl:apply-templates select="/ext-error/sql-error/error-code" />
-</xsl:template>
-
-
+<?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="driver" select="'org.enhydra.instantdb.jdbc.idbDriver'"/>
+<xsl:param name="datasource" select="'jdbc:idb:../../instantdb/sample.prp'"/>
+<!-- Build an invalid query --><xsl:param name="query" select="'SELECT * FROM import1X'"/>
+ <xsl:template match="/">
+ <!-- 1. Make the connection -->
+ <xsl:variable name="db" select="sql:new($driver, $datasource)"/>
+ <!--2. Execute the query -->
+ <xsl:variable name="table" select='sql:query($db, $query)'/>
+ <xsl:apply-templates select="$table/row-set" />
+ <xsl:apply-templates select="$table/ext-error" />
+ <!-- 3. Close the connection -->
+ <xsl:value-of select="sql:close($db)"/>
+ </xsl:template>
+
+ <xsl:template match="row-set">
+ <HTML>
+ <HEAD>
+ <TITLE>List of products</TITLE>
+ </HEAD>
+ <BODY>
+ <TABLE border="1">
+ <TR>
+ <xsl:for-each select="/row-set/column-header">
+ <TH><xsl:value-of select="@column-label"/></TH>
+ </xsl:for-each>
+ </TR>
+ <xsl:apply-templates select="/row-set/row"/>
+ </TABLE>
+ </BODY>
+ </HTML>
+ </xsl:template>
+
+ <xsl:template match="row">
+ <TR><xsl:apply-templates select="col"/></TR>
+ </xsl:template>
+
+ <xsl:template match="col">
+ <TD><xsl:value-of select="text()"/></TD>
+ </xsl:template>
+
+ <xsl:template match="/ext-error">
+ <xsl:text>Woops, an error occured: </xsl:text>
+ <xsl:apply-templates select="/ext-error/exception-info/message" />
+ <xsl:text> -- SQL Error Code: </xsl:text>
+ <xsl:apply-templates select="/ext-error/sql-error/error-code"/>
+ </xsl:template>
</xsl:stylesheet>
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org