I'm not sure where you went wrong trying to use the interfaces in package sxpath. I would think this is the right way to go on this. You can use it something like this:
XPathEvaluator xpath = new XPathEvaluator(config);
XPathExpression exp = xpath.createExpression("//item");
NodeInfo doc = config.build(xmlSource);
XPathDynamicContext context = exp.createDynamicContext(doc);
SequenceIterator nodes = exp.iterate(context);
while (true) {
  NodeInfo node = (NodeInfo)nodes.next();
  if (node == null) break;
  ... process one node ...
Here config is the Configuration used by the TransformerFactory. Best thing is to create it yourself:
Configuration config = new Configuration();
TransformerFactory factory = new net.sf.saxon.TransformerFactoryImpl(config);
Templates templates = factory.newTemplates(xslSource);
Transformer transformer = templates.newTransformer();
transformer.transform(doc, ....);
(the above works because Saxon's NodeInfo implements the JAXP Source interface).
In the code you've shown below, you're using a DOM rather than a Saxon TinyTree, which will be a lot slower. If that's what you want to do, however, you can pass the DOM document as the input to the transformation by wrapping it in a javax.xml.transform.dom.DOMSource.
Hope this helps!
Michael Kay

From: Kevin Burges [mailto:KevinBurges@formedix.com]
Sent: 09 December 2008 12:26
To: Mailing list for the SAXON XSLT and XQuery processor
Subject: Re: [saxon] Passing NodeSet parameter from Java

I managed to get it working using s9api using java 1.6.0. It was superbly fast which was great, but I do need to get it working on 1.4.2 at the moment. To that end I tried to change my code to use the sxpath classes. This seemed like it might work, then i couldn't figure out how to get the xpath to return a nodeset, I could only get it to give me a string.

I then tried changing back to my original code using jaxen, but trying to not load the document twice. Here's the gist of the orginal code again:
                Source xslSource = new StreamSource(oXSLFile);
               Source xmlSource =
new StreamSource(oXMLFile);

               TransformerFactory oTransFactory = TransformerFactory.newInstance();

               Transformer oTransformer = oTransFactory.newTransformer(xslSource);

               Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(oXMLFile);

               for (however many times)


                       org.jaxen.dom.XPath oPath =
new org.jaxen.dom.XPath(sElementPath);
new ETFTransform.TransformNamespaceResolver(oTransform.getODMNamespaceURI()));        
SELECTED_ELEMENTS, oPath.selectNodes(doc));
new StreamResult(new FileOutputStream(oOutput)));

So I have a tree for "doc" - is this a TinyTree? If not, how do I get it to use TinyTree? I tried using doc as the input to transform() to avoid reparsing the input but it won't let me pass a Document, it needs a Source. Can I get it to use the tree I already have somehow?

I don't know why I'm finding this stuff so hard but it's very confusing trying to work our what's going on and what classes are actually being used.