xsl-list
[Top] [All Lists]

Abstracting XPath queries

2003-02-26 09:23:20
I am working on moving the code base of an existing application to and
XML/XSL engine.  The engine makes decisions based on rules that it gets
from one of 3 files:

workspace.xml
project.xml
global.xml

For example, if I want the display name for a field I am pulling from a
database:

<xsl:template name="displayName">
        <xsl:param name="currentRow" />
        <xsl:choose>
                <xsl:when
test="document('workspace.xml')/ROW[TableName=$tableName and
FName=$currentRow]">
                        <xsl:value-of
select="document('workspace.xml')/ROW[TableName=$tableName and
FName=$currentRow]/FDisplay" />
                </xsl:when>
                <xsl:when
test="document('project.xml')/ROW[TableName=$tableName and
FName=$currentRow]">
                        <xsl:value-of
select="document('project.xml')/ROW[TableName=$tableName and
FName=$currentRow]/FDisplay" />
                </xsl:when>
                <xsl:when
test="document('global.xml')/ROW[FName=$currentRow]">
                        <xsl:value-of
select="document('global.xml')/ROW[FName=$currentRow]/FDisplay" />
                </xsl:when>
                <xsl:otherwise>
                        <xsl:value-of select="@name" />
                </xsl:otherwise>
        </xsl:choose>
</xsl:template>



Now the problem I am encountering is scaling this query. There are 20
rules.  Some are only used once, some are used multiple times.  Then
there are an arbitrary number of rows in the table.

(3 file queries) * (~50 rule calls) * (Number of rows in table)

It gets out of hand quickly.

Options I have been considering:
Redesigning the rules file schemas to make them easier to navigate.
Pull all the needed rules at once and compile them into a stored
node-set.


Note:
I am still learning.  This project is the first time I have ever used
XSL in a production environment.  Up to this point I have been using it
without all but basic XPath queries.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • Abstracting XPath queries, Peter Eschenbrenner <=