Thanks Henry, > It's not entirely clear what result you are expecting. > If you want the result of evaluating "/" to be the Document node returned by com.anite.connect.utility.XML.newDocument(), > you can try adding the new text nodes in an appropriate place in that DOM tree.
> If you want the result of evaluating "/" to be the root node of the original input document, > you can use variables to work with the two different contexts. What I want is actually the second option, and I did indeed obtain the right result by using a variable. I think the fact that my XSL Extension creates nodes out of nothing is the root of my misunderstanding. In this specific case it would appear more logical if the context remained that of the main document, because the context of the nodes created by the function itself is meaningless: I only return a nodelist to be able to call for-each on it. However, I agree that there are other situations where it is more logical for the context to be that of the newly created nodes. Anyway, I'll simply need to fully document my extension to indicate how to use it and I'll be OK. Thanks again for your help. Regards -----Original Message----- From: Henry Zongaro [mailto:[EMAIL PROTECTED] Sent: 29 May 2006 19:15 To: Schmidlin, Franck Cc: xalan-j-users@xml.apache.org Subject: Re: XSL extension, result context Hi, Franck. "Schmidlin, Franck" <[EMAIL PROTECTED]> wrote on 2006-05-22 05:40:05 AM: > The function looks like: > > public static org.w3c.dom.traversal.NodeIterator tokenize( > org.apache.xalan.extensions.ExpressionContext iContext, > String istrValue, > String istrSeparator) > throws javax.xml.transform.TransformerException > { > org.apache.xpath.NodeSet result = new > org.apache.xpath.NodeSet(); > org.w3c.dom.Document dom = > com.anite.connect.utility.XML.newDocument(); > > if(istrValue != null || istrSeparator != null) > { > java.util.StringTokenizer tokenizer = > new java.util.StringTokenizer(istrValue, > istrSeparator); > > while(tokenizer.hasMoreElements()) > { > > result.addNode(dom.createTextNode(tokenizer.nextToken())); > } > } > return result; > } > > if I use it in a for each statement, the context seems to point to > nothing (i.e. <xsl:copy-of select="/"/> returns nothing, and my > apply-templates returns nothing) : It's not entirely clear what result you are expecting. It's always best to include a complete, stand-alone test case along with the expected output. The text nodes that you are creating are not part of a DOM tree, so when your stylesheet evaluates the XPath expression "/" with one of those text nodes as the context node, the result is the root node for the text node, which is an empty node set in this case. If you want the result of evaluating "/" to be the Document node returned by com.anite.connect.utility.XML.newDocument(), you can try adding the new text nodes in an appropriate place in that DOM tree. If you want the result of evaluating "/" to be the root node of the original input document, you can use variables to work with the two different contexts. For example, <xsl:variable name="inputRoot" select="/"/> <xsl:for-each select="java:MyXslt.tokenize( string(/message//request_summary/TaskList),',')"> <xsl:comment>Task ID: <xsl:value-of select="."/></xsl:comment> <xsl:comment><xsl:copy-of select="$inputRoot"/></xsl:comment> <xsl:apply-templates select="$inputRoot/message/message_body/opti:DataSet1" > <xsl:with-param name="taskId" select="."/> </xsl:apply-templates> </xsl:for-each> I hope that helps. Thanks, Henry ------------------------------------------------------------------ Henry Zongaro Xalan development IBM SWS Toronto Lab T/L 969-6044; Phone +1 905 413-6044 mailto:[EMAIL PROTECTED] Scanned for viruses by BlackSpider MailControl Scanned for viruses by BlackSpider MailControl. The integrity and security of this message cannot be guaranteed. This email is intended for the named recipient only, and may contain confidential information and proprietary material. Any unauthorised use or disclosure is prohibited.