| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.serialize; |
| 9 |
|
| 10 |
import net.sf.saxon.lib.SaxonOutputKeys; |
| 11 |
import net.sf.saxon.om.NodeName; |
| 12 |
import net.sf.saxon.trans.XPathException; |
| 13 |
|
| 14 |
import javax.xml.transform.OutputKeys; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public class HTML40Emitter extends HTMLEmitter { |
| 20 |
|
| 21 |
static { |
| 22 |
setEmptyTag("area"); |
| 23 |
setEmptyTag("base"); |
| 24 |
setEmptyTag("basefont"); |
| 25 |
setEmptyTag("br"); |
| 26 |
setEmptyTag("col"); |
| 27 |
setEmptyTag("embed"); |
| 28 |
setEmptyTag("frame"); |
| 29 |
setEmptyTag("hr"); |
| 30 |
setEmptyTag("img"); |
| 31 |
setEmptyTag("input"); |
| 32 |
setEmptyTag("isindex"); |
| 33 |
setEmptyTag("link"); |
| 34 |
setEmptyTag("meta"); |
| 35 |
setEmptyTag("param"); |
| 36 |
} |
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public HTML40Emitter() { |
| 44 |
|
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
@Override |
| 53 |
protected boolean isHTMLElement(NodeName name) { |
| 54 |
return name.getURI().equals(""); |
| 55 |
} |
| 56 |
|
| 57 |
@Override |
| 58 |
protected void openDocument() throws XPathException { |
| 59 |
|
| 60 |
String versionProperty = outputProperties.getProperty(SaxonOutputKeys.HTML_VERSION); |
| 61 |
|
| 62 |
if (versionProperty == null) { |
| 63 |
versionProperty = outputProperties.getProperty(OutputKeys.VERSION); |
| 64 |
} |
| 65 |
|
| 66 |
if (versionProperty != null) { |
| 67 |
if (versionProperty.equals("4.0") || versionProperty.equals("4.01")) { |
| 68 |
version = 4; |
| 69 |
} else { |
| 70 |
XPathException err = new XPathException("Unsupported HTML version: " + versionProperty); |
| 71 |
err.setErrorCode("SESU0013"); |
| 72 |
throw err; |
| 73 |
} |
| 74 |
} |
| 75 |
String systemId = outputProperties.getProperty(OutputKeys.DOCTYPE_SYSTEM); |
| 76 |
String publicId = outputProperties.getProperty(OutputKeys.DOCTYPE_PUBLIC); |
| 77 |
|
| 78 |
|
| 79 |
if ("".equals(systemId)) { |
| 80 |
systemId = null; |
| 81 |
} |
| 82 |
if ("".equals(publicId)) { |
| 83 |
publicId = null; |
| 84 |
} |
| 85 |
|
| 86 |
super.openDocument(); |
| 87 |
if (systemId != null || publicId != null) { |
| 88 |
writeDocType(null, "html", systemId, publicId); |
| 89 |
} |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
} |