Subject: Re: Implementing iterative extension elements in Xalan... From: "Scott Boag/CAM/Lotus" <Scott_Boag@xxxxxxxxx> Date: Sun, 23 Apr 2000 02:20:34 -0400 |
> but I can't see how I can communicate from my element back to the Xalan > engine whether or not the iteration has completed. I'm not sure if I understand this. If you were going to implement something like <ext:my-for-each select ="foo"><blah><xsl:apply-templates/></blah></ext:my-for-each>, wouldn't you, inside your extension function, just do what ever you wanted in terms of itteration? Why does Xalan need to be aware of the fact that you're doing itteration? I would think you would do something like: public void myForEach (org.apache.xalan.xslt.XSLProcessorContext context, org.apache.xalan.xslt.ElemExtensionCall extElem) throws SAXException { String selectionString = extElem.getAttribute("select"); XPathSupport execContext = context.processor.getXMLProcessorLiaison(); XPath xpath = new XPath(); XPathProcessorImpl parser = new XPathProcessorImpl(execContext); parser.initXPath(xpath, selectionString, extElem); XObject value = xpath.execute(execContext, context.sourceNode, extElem); if(value.getType() != XObject.CLASS_NODESET) throw new SAXException("my-for-each select attribute didn't return a node set!"); NodeList nodelist = value.nodeset(); int n = nodelist.getLength(); for(int i = 0; i < n; i++) { Node contextNode = nodelist.item(i); Node sourceTree = contextNode.getOwnerDocument(); if(null == sourceTree) sourceTree = contextNode; extElem.executeChildren(context.processor, contextNode, sourceTree, context.mode); } } i.e., it would be your function that would be doing the itteration, not Xalan. You just call back to Xalan to have it execute the inner template. If you want to count from some value to some value, you could do this just as easy using the above technique. Does this do the trick?? BTW, questions like this, being processor specific, should really go onto the xalan dev list. -scott JamesW@xxxxxxxxxxxxxx u To: xsl-list@xxxxxxxxxxxxxxxx Sent by: cc: (bcc: Scott Boag/CAM/Lotus) owner-xsl-list@mulber Subject: Implementing iterative extension elements in Xalan... rytech.com 04/23/2000 12:14 AM Please respond to xsl-list Folks, Does anyone have any clues as to how I go about implementing an extension element in Xalan that permits iteration in a similar fashion to xsl:for-each? I've implemented a few simple extension elements in Xalan, but I can't see how I can communicate from my element back to the Xalan engine whether or not the iteration has completed. Has anyone successfully achieved this, or does the scope of Xalan's extension interface not permit such extension elements. Regards, James W. -------------------------------------------------------------------------- Cards etc will be on stand 1161 at CardTech SecurTech in Miami from 2nd May to 4th May. Look forward to seeing you there! -------------------------------------------------------------------------- This e-mail is from Cards Etc Pty Ltd (ACN: 069 533 302). It may contain privileged and confidential information. It is intended for the named recipient(s) only. If you are not an intended recipient, please notify us immediately by reply e-mail or by phone on +61 2 9212 7773 & delete this e-mail from your system. -------------------------------------------------------------------------- XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Implementing iterative extension el, JamesW | Thread | Cascading with <?xml-stylesheet?>, Matt Sergeant |
Implementing iterative extension el, JamesW | Date | Cascading ( Or processing twice?) h, Dan Morrison |
Month |