http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2307

*** shadow/2307 Mon Jun 25 06:53:04 2001
--- shadow/2307.tmp.25058       Mon Jun 25 06:53:04 2001
***************
*** 0 ****
--- 1,95 ----
+ +============================================================================+
+ | An extension function cannot return a NodeIterator.                        |
+ +----------------------------------------------------------------------------+
+ |        Bug #: 2307                        Product: XalanJ2                 |
+ |       Status: NEW                         Version: 2.1.0                   |
+ |   Resolution:                            Platform: Other                   |
+ |     Severity: Normal                   OS/Version: All                     |
+ |     Priority: Other                     Component: org.apache.xalan.extens |
+ +----------------------------------------------------------------------------+
+ |  Assigned To: [EMAIL PROTECTED]                                     |
+ |  Reported By: [EMAIL PROTECTED]                                    |
+ |      CC list: Cc:                                                          |
+ +----------------------------------------------------------------------------+
+ |          URL:                                                              |
+ +============================================================================+
+ |                              DESCRIPTION                                   |
+ Basically, you can't write an extension that returns 
+ org.w3c.dom.traversal.NodeIterator.  In the current version of the code, any 
+ object that implements NodeIterator must also implement 
+ org.apache.xpath.ContextNodeList.  In the current CVS, the error message is
+ 
+ javax.xml.transform.TransformerException: For extension function, could not 
+ find method org.apache.xpath.NodeSetDTM.getNodeList([ExpressionContext,] ).
+ 
+ Sample code:
+ 
+ import org.w3c.dom.traversal.NodeIterator;
+ import org.w3c.dom.traversal.NodeFilter;
+ import org.w3c.dom.DOMException;
+ import org.w3c.dom.Node;
+ 
+ import javax.xml.parsers.DocumentBuilderFactory;
+ import javax.xml.parsers.DocumentBuilder;
+ 
+ public class Iterator implements NodeIterator {
+   private int mlngCount;
+   private org.w3c.dom.Document mobjDocument;
+ 
+   public Iterator() throws javax.xml.parsers.ParserConfigurationException {
+     DocumentBuilderFactory objFactory =
+ DocumentBuilderFactory.newInstance();
+     DocumentBuilder objBuilder = objFactory.newDocumentBuilder();
+     mobjDocument = objBuilder.newDocument();
+   }
+   
+   public NodeIterator getNodeList() {
+     return this;
+   }
+      
+   public Node getRoot() {
+     return mobjDocument;
+   }
+ 
+   public int getWhatToShow() {
+     return NodeFilter.SHOW_ALL;
+   }
+ 
+   public NodeFilter getFilter() {
+     return null;
+   }
+ 
+   public boolean getExpandEntityReferences() {
+     return false;
+   }
+ 
+   public Node nextNode() throws DOMException {
+     mlngCount++;
+     if (mlngCount<10) {
+       org.w3c.dom.Element objElement = mobjDocument.createElement("Hello");
+       objElement.setAttribute("value", String.valueOf(mlngCount));
+       return objElement;
+     }
+     return null;
+   }
+ 
+   public Node previousNode() throws DOMException {
+     throw (new DOMException(DOMException.NOT_SUPPORTED_ERR, "This is a
+ custom iterator which cannot go back."));
+   }
+ 
+   public void detach() {
+     // Empty
+   }
+ }
+ 
+ and I'm using the following file to test it:
+ 
+ <?xml version="1.0"?> 
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
+                 xmlns:java="http://xml.apache.org/xslt/java";
+                 version="1.0">
+   <xsl:template match="/">
+       <xsl:for-each select="java:getNodeList(java:Iterator.new())" />
+   </xsl:template>
+ </xsl:stylesheet>
\ No newline at end of file

Reply via email to