canonicalEncoding = Encodings.convertMime2JavaEncoding(_encoding);
OutputStreamWriter writer =
new OutputStreamWriter(System.out, canonicalEncoding);
}
catch (java.io.UnsupportedEncodingException e) {
ErrorMsg msg = new ErrorMsg(ErrorMsg.UNSUPPORTED_ENCODING,
_encoding, this);
parser.reportError(Constants.WARNING, msg);
}
outputProperties.setProperty(OutputKeys.ENCODING, _encoding);
}
// Should the XML header be omitted - translate to true/false
attrib = getAttribute("omit-xml-declaration");
if (!attrib.equals(Constants.EMPTYSTRING)) {
if (attrib.equals("yes")) {
_omitHeader = true;
}
outputProperties.setProperty(OutputKeys.OMIT_XML_DECLARATION, attrib);
}
// Add 'standalone' decaration to output - use text as is
_standalone = getAttribute("standalone");
if (_standalone.equals(Constants.EMPTYSTRING)) {
_standalone = null;
}
else {
outputProperties.setProperty(OutputKeys.STANDALONE, _standalone);
}
// Get system/public identifiers for output DOCTYPE declaration
_doctypeSystem = getAttribute("doctype-system");
if (_doctypeSystem.equals(Constants.EMPTYSTRING)) {
_doctypeSystem = null;
}
else {
outputProperties.setProperty(OutputKeys.DOCTYPE_SYSTEM, _doctypeSystem);
}
_doctypePublic = getAttribute("doctype-public");
if (_doctypePublic.equals(Constants.EMPTYSTRING)) {
_doctypePublic = null;
}
else {
outputProperties.setProperty(OutputKeys.DOCTYPE_PUBLIC, _doctypePublic);
}
// Names the elements of whose text contents should be output as CDATA
_cdata = getAttribute("cdata-section-elements");
if (_cdata.equals(Constants.EMPTYSTRING)) {
_cdata = null;
}
else {
StringBuffer expandedNames = new StringBuffer();
StringTokenizer tokens = new StringTokenizer(_cdata);
// Make sure to store names in expanded form
while (tokens.hasMoreTokens()) {
String qname = tokens.nextToken();
if (!XML11Char.isXML11ValidQName(qname)) {
ErrorMsg err = new ErrorMsg(ErrorMsg.INVALID_QNAME_ERR, qname, this);
parser.reportError(Constants.ERROR, err);
}
expandedNames.append(
parser.getQName(qname).toString()).append(' ');
}