I have an app that currently uses Xalan
(which I'm trying to move over to Saxon) to run some XSLT and pass in some
parameters. One of these parameters is a NodeSet. In some paths through
the code there is only one element in it and in some there are multiple,
so it always gets put in a NodeSet to be consistent.
Either (for a single node):
oPathEffective = new
= (Node) oPathEffective.selectSingleNode(doc);
NodeSet oNodeSetEffective = new NodeSet(oNode);
or (for multiple nodes):
oNodeListEffective = (ArrayList) oPathEffective.selectNodes(doc);
NodeSet oNodeSetEffective = new NodeSet();
Iterator oIter = oNodeListEffective.iterator();
Node oNode = (Node)
I know the code isn't great anyway,
but that's how its written at the moment.
This works under Xalan, however when
I switch to using Saxon using:
I get errors thrown when I try to access
the variable, for example when I try:
I get an error:
Required item type of first
operand of '/' is node(); supplied value has item type java:org.apache.xpath.NodeSet
In the code paths that only ever pass one element into it I tried changing
the code to pass a Node rather than a NodeSet:
oNode = (Node) oPathEffective.selectSingleNode(doc);
This fixes the problem for that case,
as a Node is passed which is what Saxon seems to be expecting. I can't
find a way though to get it to let me use the NodeSet I'm passing in, it
always gives me that error. Is there something stupid I'm doing wrong?
It seems pretty trivial but I'm obviously missing something. Any pointers
would be greatly appreciated.