public void writeXdmValue(XdmValue value, Destination destination) throws SaxonApiException {
try {
Receiver out = destination.getReceiver(config);
out.setPipelineConfiguration(config.makePipelineConfiguration());
out = new NamespaceReducer(out);
TreeReceiver tree = new TreeReceiver(out);
tree.open();
tree.startDocument(0);
for (Iterator<XdmItem> it = value.iterator(); it.hasNext();) {
XdmItem item = it.next();