I often run into performance issues when XSL converts large amounts of data to HTML. This data is usually just a couple of very large tables of approximately this form:
<table>
<record>
<group>1</group>
<data>abc</abc>
</record>
<record>
<group>1</group>
<data>def</abc>
</record>
<record>
<group>2</group>
<data>ghi</abc>
</record>
</table>
During the conversion, I want to visually group records like this
+--------------+
| Group 1 |
+--------------+
| abc |
| def |
+--------------+
| Group 2 |
+--------------+
| ghi |
+--------------+
This stupid implementation is this (from http://exslt.org . The actual implementation is a little different, it's just an example)
<xsl:for-each select="set:distinct(/table/record/group)">
<xsl:variable name="group" select="."/>
<xsl:for-each select="/table/record[group = $group]">
</xsl:for-each>
</xsl:for-each>
, O(n^2). , . , , , 5000. 50 . , , O(n^3)
:
- Java , . XSLT, .
- , , Xerces/Xalan/Exslt,
- -
/table/record/group - ,
<xsl:apply-templates/> , <xsl:for-each/>.
, O(n^2)?