use of org.exist.util.serializer.ExtendedDOMSerializer in project exist by eXist-db.
the class XMLDBXUpdate method evalWithCollection.
/* (non-Javadoc)
* @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
*/
public Sequence evalWithCollection(Collection c, Sequence[] args, Sequence contextSequence) throws XPathException {
final NodeValue data = (NodeValue) args[1].itemAt(0);
final StringWriter writer = new StringWriter();
final Properties properties = new Properties();
properties.setProperty(OutputKeys.INDENT, "yes");
final DOMSerializer serializer = new ExtendedDOMSerializer(context.getBroker(), writer, properties);
try {
serializer.serialize(data.getNode());
} catch (final TransformerException e) {
logger.debug("Exception while serializing XUpdate document", e);
throw new XPathException(this, "Exception while serializing XUpdate document: " + e.getMessage(), e);
}
final String xupdate = writer.toString();
long modifications = 0;
try {
final XUpdateQueryService service = (XUpdateQueryService) c.getService("XUpdateQueryService", "1.0");
logger.debug("Processing XUpdate request: {}", xupdate);
modifications = service.update(xupdate);
} catch (final XMLDBException e) {
throw new XPathException(this, "Exception while processing xupdate: " + e.getMessage(), e);
}
context.getRootExpression().resetState(false);
return new IntegerValue(modifications);
}
Aggregations