Project

Profile

Help

Bug #5747 » Example2.xslt

Herbert Brückner, 2022-11-29 10:35

 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:sql="http://saxon.sf.net/sql"
xmlns:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:saxon="http://saxon.sf.net/"
extension-element-prefixes="saxon"
version="3.1">

<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>


<xsl:variable name="connection" select="sql:connect(map{ 'database':'my_DB_URL',
'user':'my_user', 'password':'my_pwd', 'autoCommit':true()})"/>


<xsl:template match="/">
<!-- Example 1:
Expect: all rows are updated
Observed: no row were updated
-->
<xsl:variable name="test1" as="function(*)"
select="sql:prepared-statement($connection, 'update DATASTORE.SQL_TEST set VALUE = ? ') " />
<saxon:do action="$test1( 'wanted' )" />
<!-- Example 2:
Expect: first row is updated
Observed: no row were updated
-->
<xsl:variable name="test2" as="function(*)" select="sql:prepared-statement($connection, 'update DATASTORE.SQL_TEST set VALUE = ? where KEY = ?')" />
<saxon:do action="$test2( 'key 1', 'now wanted' )" />

</xsl:template>

</xsl:stylesheet>
(3-3/3)