in src/org/apache/xalan/xsltc/compiler/Output.java [142:312]
public void parseContents(Parser parser) {
final Properties outputProperties = new Properties();
// Ask the parser if it wants this <xsl:output> element
parser.setOutput(this);
// Do nothing if other <xsl:output> element has higher precedence
if (_disabled) return;
String attrib = null;
// Get the output version
_version = getAttribute("version");
if (_version.equals(Constants.EMPTYSTRING)) {
_version = null;
}
else {
outputProperties.setProperty(OutputKeys.VERSION, _version);
}
// Get the output method - "xml", "html", "text" or <qname> (but not ncname)
_method = getAttribute("method");
if (_method.equals(Constants.EMPTYSTRING)) {
_method = null;
}
if (_method != null) {
_method = _method.toLowerCase();
if ((_method.equals("xml"))||
(_method.equals("html"))||
(_method.equals("text"))||
((XML11Char.isXML11ValidQName(_method)&&(_method.indexOf(":") > 0)))) {
outputProperties.setProperty(OutputKeys.METHOD, _method);
} else {
reportError(this, parser, ErrorMsg.INVALID_METHOD_IN_OUTPUT, _method);
}
}
// Get the output encoding - any value accepted here
_encoding = getAttribute("encoding");
if (_encoding.equals(Constants.EMPTYSTRING)) {
_encoding = null;
}
else {
try {
// Create a write to verify encoding support
String canonicalEncoding;
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(' ');
}
_cdata = expandedNames.toString();
outputProperties.setProperty(OutputKeys.CDATA_SECTION_ELEMENTS,
_cdata);
}
// Get the indent setting - only has effect for xml and html output
attrib = getAttribute("indent");
if (!attrib.equals(EMPTYSTRING)) {
if (attrib.equals("yes")) {
_indent = true;
}
outputProperties.setProperty(OutputKeys.INDENT, attrib);
}
else if (_method != null && _method.equals("html")) {
_indent = true;
}
// indent-amount: extension attribute of xsl:output
_indentamount = getAttribute(
lookupPrefix("http://xml.apache.org/xalan"), "indent-amount");
// Hack for supporting Old Namespace URI.
if (_indentamount.equals(EMPTYSTRING)){
_indentamount = getAttribute(
lookupPrefix("http://xml.apache.org/xslt"), "indent-amount");
}
if (!_indentamount.equals(EMPTYSTRING)) {
outputProperties.setProperty("indent_amount", _indentamount);
}
// Get the MIME type for the output file
_mediaType = getAttribute("media-type");
if (_mediaType.equals(Constants.EMPTYSTRING)) {
_mediaType = null;
}
else {
outputProperties.setProperty(OutputKeys.MEDIA_TYPE, _mediaType);
}
// Implied properties
if (_method != null) {
if (_method.equals("html")) {
if (_version == null) {
_version = HTML_VERSION;
}
if (_mediaType == null) {
_mediaType = "text/html";
}
}
else if (_method.equals("text")) {
if (_mediaType == null) {
_mediaType = "text/plain";
}
}
}
// Set output properties in current stylesheet
parser.getCurrentStylesheet().setOutputProperties(outputProperties);
}