http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2398 *** shadow/2398 Fri Jun 29 08:31:46 2001 --- shadow/2398.tmp.582 Fri Jun 29 08:31:46 2001 *************** *** 0 **** --- 1,102 ---- + +============================================================================+ + | Extension element cannot get NodeList from context Node | + +----------------------------------------------------------------------------+ + | Bug #: 2398 Product: XalanJ2 | + | Status: NEW Version: 2.1.0 | + | Resolution: Platform: PC | + | Severity: Normal OS/Version: Windows NT/2K | + | Priority: Other Component: org.apache.xalan.stree | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + My extension element can get the context Node from the XSLProcessorContext + object, but it cannot get the list of child nodes from that Node, even though + Node.hasChildNodes() returns true; + + Here is my XML: + + <ihw:sizes> + <ihw:size>XS</ihw:size> + <ihw:size>S</ihw:size> + <ihw:size>M</ihw:size> + <ihw:size>L</ihw:size> + <ihw:size>XL</ihw:size> + <ihw:size>1</ihw:size> + <ihw:size>3</ihw:size> + <ihw:size>5</ihw:size> + <ihw:size>7</ihw:size> + <ihw:size>30</ihw:size> + <ihw:size>32</ihw:size> + <ihw:size>33</ihw:size> + <ihw:sizes> + + My extension element method looks like this: + + public static void sortsizes(XSLProcessorContext context, ExtElementCall elem) { + + Node ctxNode = context.getContextNode(); + System.out.println("Context node has children = " + ctxNode.hasChildNodes()); + try { + NodeList sizeNodes = ctxNode().getChildNodes(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + + + + Here is my output: + + Context node has children = true + DOM ERROR! class: org.apache.xalan.stree.ElementImplWithNS + java.lang.RuntimeException: Function not supported! + at org.apache.xml.utils.UnImplNode.error(UnImplNode.java:87) + at org.apache.xml.utils.UnImplNode.getChildNodes(UnImplNode.java:168) + at com.ihw.xslt.Extensions.sortsizes(Extensions.java:166) + at java.lang.reflect.Method.invoke(Native Method) + at org.apache.xalan.extensions.ExtensionHandlerJavaClass.processElement + (ExtensionHandlerJavaClass.java:418) + at org.apache.xalan.templates.ElemExtensionCall.execute + (ElemExtensionCall.java:305) + at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates + (TransformerImpl.java, Compiled Code) + at org.apache.xalan.templates.ElemLiteralResult.execute + (ElemLiteralResult.java, Compiled Code) + at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates + (TransformerImpl.java, Compiled Code) + at org.apache.xalan.templates.ElemLiteralResult.execute + (ElemLiteralResult.java, Compiled Code) + at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates + (TransformerImpl.java, Compiled Code) + at org.apache.xalan.templates.ElemLiteralResult.execute + (ElemLiteralResult.java, Compiled Code) + at org.apache.xalan.templates.ElemForEach.transformSelectedNodes + (ElemForEach.java, Compiled Code) + at org.apache.xalan.templates.ElemApplyTemplates.execute + (ElemApplyTemplates.java:193) + at org.apache.xalan.transformer.TransformerImpl.executeChildTemplates + (TransformerImpl.java, Compiled Code) + at org.apache.xalan.transformer.TransformerImpl.applyTemplateToNode + (TransformerImpl.java:2134) + at org.apache.xalan.transformer.TransformerImpl.transformNode + (TransformerImpl.java, Compiled Code) + at org.apache.xalan.transformer.TransformerImpl.run + (TransformerImpl.java:3070) + at java.lang.Thread.run(Thread.java:479) + + + + + I'm writing the extension element to do a custom sorting schema (i.e. so that + the sizes are ordered by XS, S, M, L, XL, etc. instead of alphabetical order. + Do the current facilities for writing extension elements not support modifying + the Nodes in the xml? + + Thanks, + + Michael \ No newline at end of file
