xsl-list
[Top] [All Lists]

Re: [xsl] question on EXSLT data partitioning

2010-10-20 08:12:00
Or does the mention of EXSLT mean you need a 1.0 solution?
Yes, as you may know DataPower Processore is XSLT 1.0 + EXSLT + proprietary
extensions.

And why exactly is a recursive solution considered unsuitable for the
task? (Is it because you need to run this on processors that don't
optimize tail calls?)
It was not unsuitable, I just wondered that the recursive solution was an
overkill.

And below (and now tested version) from Martin Honnen is what I looked for:
$ cat ent2.xsl
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";

  <xsl:output omit-xml-declaration="yes" />

  <xsl:variable name="N" select="3"/>

  <xsl:template match="Entity">
    <argument><xsl:value-of select="."/></argument>
  </xsl:template>

  <xsl:template match="/root/data">
    <all>
      <xsl:for-each select="Entity[(position() - 1) mod $N = 0]">
        <arguments>
          <xsl:apply-templates select=". |
            following-sibling::Entity[position() &lt; $N]"/>
        </arguments>
      </xsl:for-each>
    </all>
  </xsl:template>

</xsl:stylesheet>
$


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
Fixpack team lead
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



From:       Michael Kay <mike(_at_)saxonica(_dot_)com>
To:         xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date:       10/19/2010 08:09 PM
Subject:    Re: [xsl] question on EXSLT data partitioning




What's wrong with

<xsl:variable name="Entities" select="child::Entity"/>
<xsl:for-each select="1 to (count($Entities) idiv $PARTITION_SIZE">
<partition>
<xsl:copy-of select="subsequence($Entities, (1 + (. - 1) *
$PARTITION_SIZE), $PARTITION_SIZE)"/>
</partition>
</xsl:for-each>

Or does the mention of EXSLT mean you need a 1.0 solution?

And why exactly is a recursive solution considered unsuitable for the
task? (Is it because you need to run this on processors that don't
optimize tail calls?)

Michael Kay
Saxonica

Hello,

yesterday I was asked by a colleague on data partitioning.
He wanted to partition 100000s of Entities in blocks of 1000
for sending a single Database update for 1000 entities.

Below is the simplified input, partition size is N=3 and the
requested output. Below that is the solution I provided.

Here are my questions:
* can this task be done without recursion in EXSLT?
   [the colleage did not like the idea of doing the partitioning with
    just XPath (1<=position()<=1000, 1001<=position()<=2000, ...)
    because of the 6 digit number of entities]
* is the conversion of Entity to argument by apply-templates
   the way to go?



--~------------------------------------------------------------------
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>
--~--




--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>