List<Object> results = new ArrayList<Object>();
Class<?> type = returnType.getType();
while (result.next())
{
XQItem item = result.getItem();
if (Node.class.isAssignableFrom(type) || Node[].class.isAssignableFrom(type))
{
results.add(getItemValue(item));
}
else if (String.class.isAssignableFrom(type) || String[].class.isAssignableFrom(type))
{
results.add(item.getItemAsString(null));
}
else if (XMLStreamReader.class.isAssignableFrom(type) || XMLStreamReader[].class.isAssignableFrom(type))
{
try
{
results.add(item.getItemAsStream());
}
catch (XQException e)
{
throw new TransformerException(XmlMessages.streamNotAvailble(getName()));
}
}
else
{
//This can be a JAXB bound object instance depending on whether the CommonHandler has been set
try
{
results.add(item.getObject());
}
catch (XQException e)
{
throw new TransformerException(XmlMessages.objectNotAvailble(getName()));