{
value = (XObject) obj;
}
else if (obj instanceof String)
{
value = new XString((String) obj);
}
else if (obj instanceof Boolean)
{
value = new XBoolean(((Boolean) obj).booleanValue());
}
else if (obj instanceof Double)
{
value = new XNumber(((Double) obj).doubleValue());
}
else if (obj instanceof DocumentFragment)
{
int handle = xctxt.getDTMHandleFromNode((DocumentFragment)obj);
value = new XRTreeFrag(handle, xctxt);
}
else if (obj instanceof DTM)
{
DTM dtm = (DTM)obj;
DTMIterator iterator = new DescendantIterator();
// %%ISSUE%% getDocument may not be valid for DTMs shared by multiple
// document trees, eg RTFs. But in that case, we shouldn't be trying
// to iterate over the whole DTM; we should be iterating over
// dtm.getDocumentRoot(rootNodeHandle), and folks should have told us
// this by passing a more appropriate type.
iterator.setRoot(dtm.getDocument(), xctxt);
value = new XNodeSet(iterator);
}
else if (obj instanceof DTMAxisIterator)
{
DTMAxisIterator iter = (DTMAxisIterator)obj;
DTMIterator iterator = new OneStepIterator(iter, -1);
value = new XNodeSet(iterator);
}
else if (obj instanceof DTMIterator)
{
value = new XNodeSet((DTMIterator) obj);
}
else if (obj instanceof NodeIterator)
{
value = new XNodeSet(new org.apache.xpath.NodeSetDTM(((NodeIterator)obj), xctxt));
}
else if (obj instanceof org.w3c.dom.Node)
{
value =
new XNodeSet(xctxt.getDTMHandleFromNode((org.w3c.dom.Node) obj),
xctxt.getDTMManager());
}
else
{
value = new XString(obj.toString());
}
int type = value.getType();
String s;