Processor qtproc = runtime.getProcessor();
DocumentBuilder builder = qtproc.newDocumentBuilder();
builder.setBaseURI(new URI("http://example.com/"));
XQueryCompiler xqcomp = qtproc.newXQueryCompiler();
XQueryExecutable xqexec = xqcomp.compile(".");
XQueryEvaluator xqeval = xqexec.load();
xqeval.setContextItem(doc);
serializer = new Serializer();
serializer.setOutputProperty(Serializer.Property.BYTE_ORDER_MARK, serial.getByteOrderMark() ? "yes" : "no");
// FIXME: support CDATA_SECTION_ELEMENTS
if (serial.getDoctypePublic() != null) {
serializer.setOutputProperty(Serializer.Property.DOCTYPE_PUBLIC, serial.getDoctypePublic());
}
if (serial.getDoctypeSystem() != null) {
serializer.setOutputProperty(Serializer.Property.DOCTYPE_SYSTEM, serial.getDoctypeSystem());
}
if (serial.getEncoding() != null) {
serializer.setOutputProperty(Serializer.Property.ENCODING, serial.getEncoding());
}
serializer.setOutputProperty(Serializer.Property.ESCAPE_URI_ATTRIBUTES, serial.getEscapeURIAttributes() ? "yes" : "no");
serializer.setOutputProperty(Serializer.Property.INCLUDE_CONTENT_TYPE, serial.getIncludeContentType() ? "yes" : "no");
serializer.setOutputProperty(Serializer.Property.INDENT, serial.getIndent() ? "yes" : "no");
if (serial.getMediaType() != null) {
serializer.setOutputProperty(Serializer.Property.MEDIA_TYPE, serial.getMediaType());
}
if (serial.getMethod() != null) {
serializer.setOutputProperty(Serializer.Property.METHOD, serial.getMethod().getLocalName());
}
if (serial.getNormalizationForm() != null) {
serializer.setOutputProperty(Serializer.Property.NORMALIZATION_FORM, serial.getNormalizationForm());
}
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, serial.getOmitXMLDeclaration() ? "yes" : "no");
if (serial.getStandalone() != null) {
String standalone = serial.getStandalone();
if ("true".equals(standalone)) {
serializer.setOutputProperty(Serializer.Property.STANDALONE, "yes");
} else if ("false".equals(standalone)) {
serializer.setOutputProperty(Serializer.Property.STANDALONE, "no");
}
// What about omit?
}
serializer.setOutputProperty(Serializer.Property.UNDECLARE_PREFIXES, serial.getUndeclarePrefixes() ? "yes" : "no");
if (serial.getVersion() != null) {
serializer.setOutputProperty(Serializer.Property.VERSION, serial.getVersion());
}
if (uri == null) {
serializer.setOutputStream(out);
} else {
File file = URIUtils.getFile(uri);
runtime.finest("com.xmlcalabash.io", null, "Attempt to write file: " + uri);
//FileOutputStream fos = new FileOutputStream(file);
//serializer.setOutputStream(fos);
}
xqeval.setDestination(serializer);
xqeval.run();
if (uri == null && runtime.getDebug()) {
System.out.println("\n--<document boundary>--------------------------------------------------------------------------");
}
} catch (URISyntaxException use) {