Hi All, I have notice some really odd behavior when using org.apache.xpath.NodeSet.
I use it in two different ways. The first, is I have some custom extension functions that return a NodeSet, that I can then loop over. They work fine. Then, when I had to collect a range of different nodes to work with (kind of like a preprocessing step) I created one directly and added nodes to it. They added correctly, however I can no longer use xsl:for-each. I'll explain more below: I have a function (let's call it myfunction) that does some stuff and returns an instance of org.apache.xpath.NodeSet. When I have the following: <xsl:for-each select="prefix:myfunction(.)"> <!-- Do something here --> </xsl:for-each> I have no problems at all. for-each iterates over my node set without a problem (for information purposes, it's a NodeSet of text nodes). I then had a requirement for some preprocessing of a file, and collecting a bunch of nodes, so I thought I'd use NodeSet again, but this time I did the following: <xsl:variable name="nodebucket" select="java:org.apache.xpath.NodeSet.new()"/> <!-- next I have a range of apply-templates that pass the variable nodebucket as a parameter, that performs the following at various places <xsl:variable name="tmp" select="java:addNode($nodebucket, .)"/> this works fine, as is indicated by the logging statement below --> <log:debug message="number of nodes to process {java:size($nodebucket) + 1}"/> <!--this prints out the correct value of 33 --> <xsl:for-each select="$nodebucket"> <!--this never executes! --> <log:debug message="processing page"/> </xsl:for-each> <log:debug message="processing complete"/> I'm wondering why in one situation using NodeSet works fine, but in the other it's ignored (the contents of the second xsl:for-each is never executed, i.e. the loop doesn't iterate over the NodeSet. No errors, it just doesn't iterate over it. Can anyone shed some light into why using NodeSet works in one situation but not in the other? Cheers Adam Enjoy a better web experience. Upgrade to the new Internet Explorer 8 optimised for Yahoo!7. Get it now.