I'm implementing the function as an ExtensionFunctionCall subclass.
I did some experimenting and the following code seems to do what I want:

public SequenceIterator call(SequenceIterator[] arguments, XPathContext context) throws XPathException {
            // ...
            ComplexContentOutputter outputter = new ComplexContentOutputter();
            outputter.setPipelineConfiguration(pipelineConfig);
            outputter.setReceiver(receiver);
           
            outputter.open();         
            Item item;
            for(SequenceIterator si : arguments) {
                while( (item = si.next()) != null) {
                    outputter.append(item, 0, NodeInfo.ALL_NAMESPACES);
                }
            }
            outputter.close();
            // ...
}

Is this the correct way to use the API?


best regards,

marko


From: Michael Kay [mike@saxonica.com]
Sent: Thursday, May 27, 2010 11:28
To: 'Mailing list for the SAXON XSLT and XQuery processor'
Subject: Re: [saxon] Parsing XPath sequences in extension function

I don't really understand your question (especially in conjunction with the title of the post).
 
What interface are you using for writing the extension function?
 
The node will be supplied as an instance of net.sf.saxon.om.NodeInfo, and you can use the methods on that interface to navigate from that node to its descendants. I'm not sure why you want to do this in an extension function, however - processing XML data using XPath/XSLT is generally much easier than doing it in Java.
 

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay



From: Asplund Marko [mailto:marko.asplund@ixonos.com]
Sent: 27 May 2010 07:19
To: saxon-help@lists.sourceforge.net
Subject: [saxon] Parsing XPath sequences in extension function

Hi,

I'm trying to write a Saxon extension function that would receive an element node as input and process the element subtree.
What would be the best way to process the input element?
Can I e.g. transform the input from SequenceIterator to a SAX event stream in order to process it?

best regards,
marko