This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Effecient element "filtering" technique recommendations.
- From: "Edward L. Knoll" <ed dot knoll at cosd dot fedex dot com>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Mon, 07 Oct 2002 08:15:41 -0600
- Subject: [xsl] Effecient element "filtering" technique recommendations.
- Organization: WSCR
- References: <3D4AF861.54A15060@cosd.fedex.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
We have some XML which effectively represents the contents of a table.
Each row from the table is an element; each column in a row is a
subelement within the row. The XML we generate for the table could
contain more columns than we actually want to process/display.
I have another element which identifies all of the columns to be
processed/displayed. The subelements of this element have the same
names as the row columns.
I'm looking for recommendations on ways in which we can only process the
row columns which correspond to the other columns. My current approach
is adding approximately 40% onto our total XSL processing time. I've
included XML examples and (simplified versions) of the templates with
and without the filtering.
XML::
<Table>
<Columns>
<Column1/>
<Column2/>
<Column4/>
</Columns>
<Row>
<Column1>...</Column1>
<Column2>...</Column2>
<Column3>...</Column3>
<Column4>...</Column4>
<Column5>...</Column5>
</Row>
<Row>
<Column1>...</Column1>
<Column2>...</Column2>
<Column3>...</Column3>
<Column4>...</Column4>
<Column5>...</Column5>
</Row>
...
</Table>
XSL (fragments) w/o filtering::
<xsl:variable name="TableColumns" select="/Table/Columns/*" />
<xsl:template select="/Table/Row">
<xsl:apply-templates select="*" mode="ColumnContent" />
</xsl:template>
XSL (fragments) w/ filtering::
<xsl:variable name="TableColumns" select="/Table/Columns/*" />
<xsl:template select="/Table/Row">
<xsl:for-each select="*">
<xsl:variable name="MyName" select="name()" />
<xsl:if test="$TableColumns[name()=$MyName]" >
<xsl:apply-templates select="." mode="ColumnContent" />
</xsl:if>
</xsl:for-each>
</xsl:template>
Thanks in advance,
Ed Knoll
--
Edward L. Knoll Phone (work) : (719)484-2717
e-mail (work) : ed.knoll@cosd.fedex.com
e-mail (business): eknoll@sf-inc.com
e-mail (personal): edward@elknoll.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list