PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL BE LOST SOMEWHERE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3300 *** shadow/3300 Tue Aug 28 03:38:23 2001 --- shadow/3300.tmp.6626 Tue Aug 28 03:38:23 2001 *************** *** 0 **** --- 1,88 ---- + +============================================================================+ + | No output from key() function using NodeSet returned from extension funct | + +----------------------------------------------------------------------------+ + | Bug #: 3300 Product: XalanJ2 | + | Status: NEW Version: 2.1.0 | + | Resolution: Platform: PC | + | Severity: Normal OS/Version: All | + | Priority: Other Component: Xalan | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + I raised this on xalan-dev last week but got no responses, so I'll assume it's + a bug (?). I need to group/filter a NodeSet returned from an extension function + using keys, but get no matches returned. No exceptions are thrown. + + --Sample output -- + <?xml version="1.0" encoding="UTF-8" ?> + <top xmlns:test="com.geac.xtrane.extensions.NodeSetTest"> + <!-- Copy of NodeSet ... --> + <footag name="CONO" /> + <!-- End of NodeSet copy... --> + .. + </top> + -- end of output -- + + --Example stylesheet-- + + <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:test="com.geac.xtrane.extensions.NodeSetTest"> + <xsl:output method="xml" media-type="text/xml" /> + <xsl:key name="key1" match="footag" use="@name" /> + <xsl:template match="/"> + <xsl:variable name="test" select="test:get()" /> + <top> + <xsl:comment>Copy of NodeSet ...</xsl:comment> + <xsl:copy-of select="$test" /> + <xsl:comment>End of NodeSet copy...</xsl:comment> + <xsl:for-each select="$test"> + . + <xsl:copy-of select="key('key1','CONO')" /> + . + </xsl:for-each> + </top> + </xsl:template> + </xsl:stylesheet> + + -- Extension function -- + package com.geac.xtrane.extensions; + + import org.apache.xpath.NodeSet; + import org.w3c.dom.*; + import org.apache.xpath.XPathContext; + + public class NodeSetTest { + + public NodeSetTest() { + super(); + } + public static NodeSet get(org.apache.xalan.extensions.ExpressionContext + myContext) { + + Document doc = null; + NodeSet retns = new NodeSet(); + + doc = ((XPathContext) myContext).getDOMHelper + ().getDOMFactory(); + //doc = myContext.getContextNode().getOwnerDocument(); // Hangs + Transformer !?! + + + Element root = doc.createElement("footag"); + root.setAttribute("name","CONO"); + + retns.addNode(root) ; + + return retns; + + } + } + + Regards, + + Rob Stanley
