Subject: Re: question on EXSLT data partitioning
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Wed, 20 Oct 2010 15:11:46 +0200
|
> 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() < $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@xxxxxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Date: 10/19/2010 08:09 PM
Subject: Re: 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?
| Current Thread |
Michael Kay - 19 Oct 2010 15:33:33 -0000
- Hermann Stamm-Wilbrandt - 20 Oct 2010 13:12:01 -0000 <=
|
|