serializer.setOutputStream(out);
S9apiUtils.serialize(runtime, doc, serializer);
}
public Serializer makeSerializer(Hashtable<QName,String> options) {
Serializer serializer = new Serializer();
if (options == null) {
return serializer;
}
if (options.containsKey(_byte_order_mark)) {
serializer.setOutputProperty(Serializer.Property.BYTE_ORDER_MARK, "false".equals(options.get(_byte_order_mark)) ? "yes" : "no");
}
if (options.containsKey(_cdata_section_elements)) {
String list = options.get(_cdata_section_elements);
// FIXME: Why is list="" sometimes?
if (!"".equals(list)) {
String[] names = list.split("\\s+");
list = "";
for (String name : names) {
QName q = new QName(name, step.getNode());
list += q.getClarkName() + " ";
}
serializer.setOutputProperty(Serializer.Property.CDATA_SECTION_ELEMENTS, list);
}
}
if (options.containsKey(_doctype_public)) {
serializer.setOutputProperty(Serializer.Property.DOCTYPE_PUBLIC, options.get(_doctype_public));
}
if (options.containsKey(_doctype_system)) {
serializer.setOutputProperty(Serializer.Property.DOCTYPE_SYSTEM, options.get(_doctype_system));
}
if (options.containsKey(_encoding)) {
serializer.setOutputProperty(Serializer.Property.ENCODING, options.get(_encoding));
}
if (options.containsKey(_escape_uri_attributes)) {
serializer.setOutputProperty(Serializer.Property.ESCAPE_URI_ATTRIBUTES, "true".equals(options.get(_escape_uri_attributes)) ? "yes" : "no");
}
if (options.containsKey(_include_content_type)) {
serializer.setOutputProperty(Serializer.Property.INCLUDE_CONTENT_TYPE, "true".equals(options.get(_include_content_type)) ? "yes" : "no");
}
if (options.containsKey(_indent)) {
serializer.setOutputProperty(Serializer.Property.INDENT, "true".equals(options.get(_indent)) ? "yes" : "no");
}
if (options.containsKey(_media_type)) {
serializer.setOutputProperty(Serializer.Property.MEDIA_TYPE, options.get(_media_type));
}
if (options.containsKey(_method)) {
serializer.setOutputProperty(Serializer.Property.METHOD, options.get(_method));
}
if (options.containsKey(_normalization_form)) {
serializer.setOutputProperty(Serializer.Property.NORMALIZATION_FORM, options.get(_normalization_form));
}
if (options.containsKey(_omit_xml_declaration)) {
serializer.setOutputProperty(Serializer.Property.OMIT_XML_DECLARATION, "true".equals(options.get(_omit_xml_declaration)) ? "yes" : "no");
}
if (options.containsKey(_standalone)) {
String standalone = options.get(_standalone);
if ("true".equals(standalone)) {
serializer.setOutputProperty(Serializer.Property.STANDALONE, "yes");
} else if ("false".equals(standalone)) {
serializer.setOutputProperty(Serializer.Property.STANDALONE, "no");
}
// What about omit?
}
if (options.containsKey(_undeclare_prefixes)) {
serializer.setOutputProperty(Serializer.Property.UNDECLARE_PREFIXES, "true".equals(options.get(_undeclare_prefixes)) ? "yes" : "no");
}
if (options.containsKey(_version)) {
serializer.setOutputProperty(Serializer.Property.VERSION, options.get(_version));
}
return serializer;
}