[xslt] performance: row-col to col-row



Hi all

This is a performance question:

I have an xml that looks like
<row>
<col>1</col>
<col>2</col>
<col>3</col>
<col>4</col>
</row>
<row>
<col>5</col>
<col>6</col>
<col>7</col>
<col>8</col>
</row>
..

In the result I need to structur like:
<col>
<row>1</row>
<row>5</row>
</col>
<col>
<row>2</row>
<row>6</row>
</col>
<col>
<row>3</row>
<row>7</row>
</col>
<col>
<row>4</row>
<row>8</row>
..


It is no problem to do that, but the performance is not really good
with the following stylesheet:

<xsl:for-each select="/row[1]/col">
  <xsl:variable name="col">
     <xsl:value-of select="position()"/>
  </xsl:variable>

  <!-- I think the following xpath is slow -->
  <xsl:for-each select="/row/col[position()=$col]">
  ..
  </xsl:for-each>
</xsl:for-each>

-----

If I do that in that way the performance is miserable.
Is there an other possibility to that?

The xmls are output of an exslt:sql database query.

Bernhard
http://datenkueche.com


-------------------------------------------------
This mail sent through IMP: http://horde.org/imp/




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]