String textNodeValue;
if (rtf instanceof NodeIterator)
{
return new NodeSet((NodeIterator) rtf);
}
else
{
if (rtf instanceof String)
{
textNodeValue = (String) rtf;
}
else if (rtf instanceof Boolean)
{
textNodeValue = new XBoolean(((Boolean) rtf).booleanValue()).str();
}
else if (rtf instanceof Double)
{
textNodeValue = new XNumber(((Double) rtf).doubleValue()).str();
}
else
{
textNodeValue = rtf.toString();
}
// This no longer will work right since the DTM.
// Document myDoc = myProcessor.getContextNode().getOwnerDocument();
try
{
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document myDoc = db.newDocument();
Text textNode = myDoc.createTextNode(textNodeValue);
DocumentFragment docFrag = myDoc.createDocumentFragment();
docFrag.appendChild(textNode);
return new NodeSet(docFrag);
}
catch(ParserConfigurationException pce)
{
throw new org.apache.xml.utils.WrappedRuntimeException(pce);
}