Here's a followup for the fellow users who build their queries with XSLT.

I found the question-mark + sql:in-parameter syntax a bit inconvenient,
especially when the query is composed out of building blocks in XSLT:

        <sql:query>
          SELECT ...
          FROM ...
          WHERE ...
          <xsl:if test="$name and $filter-name">
            AND name = ?
          </xsl:if>
        </sql:query>

        <xsl:if test="$name and $filter-name">
          <sql:in-parameter nr="1" value="{$name}"/>
        </xsl:if>

As you can see, this approach is a maintainability nightmare: think of a
50 line query with dozens of parameters.

So I came up with this solution, which works very well for me.
It's somewhat similar in usage to <esql:parameter>:

        <sql:query>
          SELECT ...
          FROM ...
          WHERE ...
          <xsl:if test="$name and $filter-name">
            AND name = <sql:param value="{$name}"/>
          </xsl:if>
        </sql:query>

This is processed by an additional XSLT transformer before being fed to
the SQL transformer:

        <xsl:template match="sql:query">
          <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
          </xsl:copy>
          <xsl:for-each select=".//sql:param">
            <sql:in-parameter value="[EMAIL PROTECTED]" nr="{position()}"/>
          </xsl:for-each>
        </xsl:template>

        <xsl:template match="sql:param">
          <xsl:text>?</xsl:text>
        </xsl:template>

I think it would be useful to include this functionality in the SQL
transformer itself.


HTH
Tobia

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to