try
{
// Using XSLT to convert to a stream. Setup the source
if (!(data instanceof Node))
{
throw new ConversionException(data.getClass());
}
Node node = (Node) data;
OutputFormat outformat = OutputFormat.createCompactFormat();
outformat.setEncoding("UTF-8");
// Setup the destination
StringWriter xml = new StringWriter();
XMLWriter writer = new XMLWriter(xml, outformat);
writer.write(node);
writer.flush();
xml.flush();
String script;
if (data instanceof Element)
{
script = EnginePrivate.xmlStringToJavascriptDomElement(xml.toString());
}
else
{
script = EnginePrivate.xmlStringToJavascriptDomDocument(xml.toString());
}
OutboundVariable ov = new NonNestedOutboundVariable(script);
outctx.put(data, ov);
return ov;
}
catch (ConversionException ex)
{
throw ex;
}
catch (Exception ex)
{
throw new ConversionException(data.getClass(), ex);
}
}