[xsl] xslt performance issue position() function used in predicate very slow

Subject: [xsl] xslt performance issue position() function used in predicate very slow
From: krzysztof@xxxxxxxxxxxx
Date: Fri, 25 Aug 2006 13:20:16 +0200
Hi,

I'm processing xml files that have 150kB size
they are composed from xml blocks that contain 350 elements with int values
here is example

< obj name="obj1">
 <v>1</v>
 <v>2</v>
 <v>3</v>
 ....
 <v>350</v>
</obj>

obj blocks are  repeated many times 
in general my xslt selects some  set of <v> rows and saves in csv format
e.g. select  1,2,3,4,15,28,71,17,19 and save to csv
in my xslt I'm using below expression to select v rows

<xsl:value-of select="./v[position()=$p]"/>

( in for-each loop I assign value to $p variable)

on P4 2.8 Ghz 512MB ram it takes 20 seconds! to parse 150KB file !!!
if I comment out  this line it takes 1 second so definitely it's issue with
position()
and selecting this v values.

BTW abbreviated version doesn't wok  i.e. select="./v[$p]" but
select="./v[$p+0]" works
is this some bug ???

Thanks for any tips how to improve performance 

Chris

Current Thread