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]