Hello [EMAIL PROTECTED],
Thursday, April 04, 2002, 7:42:29 PM, Joseph Kesselman/CAM/Lotus wrote:
JKCL> Ask the folks who implemented ElementImpl -- Xerces, I presume, not Xalan.
;-) ElementImpl is my own implementation...
Perhaps I can describe the case in other words:
An extension function is sorting some elements of the source
document and adds these elements to a new NodeList. The elements
themselves were not touched.
The elements contain ID attributes. When iterating through the
NodeList, created by the extension function, the ID lookup of the
elements fails.
I really think that this is a special behaviour of Xalan.
Example:
Source-Document:
<names>
<n id="n1"/><n id="n2"/><n id="n3"/>
</names>
<list>
<e id="1" idref="n1"/><e id="2" idref="n2"/><e id="3" idref="n3"/>
<siblingOfe/>
</list>
<plist idrefs="1 2 3 />
XSLT:
1: <xsl:template match="plist">
2: <xsl:for-each select="id(@idrefs)">
3: <xsl:variable name="var1" select="id(@idref)"/>
4: </xsl:for-each>
6: <xsl:for-each select="my:func(id(@idrefs))/item">
7: <xsl:variable name="var2" select="id(@idref)"/>
8: </xsl:for-each>
9: </xsl:template>
my:func():
01:public static NodeSet func
02: ( ExpressionContext i_ExprCtxt, NodeList i_NodeList ) {
03: NodeSet newSet = new NodeSet();
04:
05: for ( int i=0; i<i_NideList.getLength(): i++) {
06: MyElementImpl item = new ElementImpl
07: (null /* Document */, i /* Index */, "item" /* Name */);
08: item.appendChild(i_NodeList.item(i));
09: newSet.addNode(item);
10: }
11: return newSet;
12:}
What is my:func() doing? All elements of the passed node list are
returned in a new list and every element has a new parent "item".
That is the following list is expected to be iterated in XSLT:6
<item><e id="1" idref="n1"/></item>
<item><e id="2" idref="n2"/></item>
<item><e id="3" idref="n3"/></item>
And this list is really iterated. But the id function in XSLT:7 fails.
Why? The element "e" were not touched. They were reordered, but they
were not modified in any way. Even the next-sibling of the last "e" in
the returned list is returning "siblingOfe" - the structure of the
elements "e" was definitely not touched! But still, the id function is
not working anymore in line XSLT:7.
Is the document reference of the elements deleted when they're
passed to an extension function? Or is the id function using the document of
the parent of an element? Why has the document gone - but not the
siblings?
Best regards,
Jens