Hi, I'm having some performance issues with a stylesheet, and I
believe it could likely be improved but I'm inexperienced with XSL.
Here is a simplified version of the problem:
+++++++++++++++Sample xml:++++++++++++++++++++++++++++++=
<information>
<rawdatas>
<rawdata>
<key>A</key>
<value>1</value>
</rawdata>
<rawdata>
<key>A</key>
<value>2</value>
</rawdata>
<rawdata>
<key>B</key>
<value>3</value>
</rawdata>
<rawdata>
<key>C</key>
<value>1</value>
</rawdata>
<rawdata>
<key>B</key>
<value>1</value>
</rawdata>
<rawdata>
<key>D</key>
<value>0</value>
</rawdata>
<rawdata>
<key>E</key>
<value>1</value>
</rawdata>
</rawdatas>
<selectedkeys>
<key>A</key>
<key>B</key>
<key>C</key>
</selectedkeys>
++++++++++++++XSL algorithm I'm using:+++++++++++++++++++++++
<xsl:template match="/information">
<xsl:call-template name="selected-keys"/>
</xsl:template>
<xsl:template name="selected-keys">
<xsl:for-each select="/information/selectedkeys/key">
<xsl:call-template name="data">
<xsl:with-param name="match" select="."/>
</xsl:call-template>
</xsl:for-each>
</xsl:template>
<xsl:template name="data">
<xsl:param name="match"/>
<xsl:for-each select="/information/rawdatas/rawdata">
<xsl:if test="key=$match">
Key <xsl:value-of select="$match"/>
matched <xsl:value-of select="value"/>
</xsl:if>
</xsl:for-each>
</xsl:template>
</information>
+++++++++++++++++++++++Outputs:+++++++++++++++++++++++++++++
Key A matched 1
Key A matched 2
Key B matched 3
Key B matched 1
Key C matched 1
I can envision a single-pass approach where the keys are hashed to a
table and the values are appended to a list on collisions, but I'm not
sure how that's accomplished in a declaritive language like XSLT.
Any help greatly appreciated.
Alex
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--