You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by sa...@apache.org on 2002/06/10 23:43:04 UTC
cvs commit: xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output SAXHTMLOutput.java
santiagopg 2002/06/10 14:43:04
Modified: java/src/org/apache/xalan/xsltc/runtime/output
SAXHTMLOutput.java
Log:
Do not insert <META>.
Revision Changes Path
1.7 +63 -87 xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/SAXHTMLOutput.java
Index: SAXHTMLOutput.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xalan/xsltc/runtime/output/SAXHTMLOutput.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- SAXHTMLOutput.java 4 Jun 2002 11:58:31 -0000 1.6
+++ SAXHTMLOutput.java 10 Jun 2002 21:43:04 -0000 1.7
@@ -1,5 +1,5 @@
/*
- * @(#)$Id: SAXHTMLOutput.java,v 1.6 2002/06/04 11:58:31 tmiller Exp $
+ * @(#)$Id: SAXHTMLOutput.java,v 1.7 2002/06/10 21:43:04 santiagopg Exp $
*
* The Apache Software License, Version 1.1
*
@@ -74,7 +74,7 @@
import org.apache.xalan.xsltc.runtime.AttributeList;
public class SAXHTMLOutput extends SAXOutput {
- private boolean _headTagOpen = false;
+
private String _mediaType = "text/html";
public SAXHTMLOutput(ContentHandler handler, String encoding)
@@ -89,6 +89,67 @@
super(handler, lex, encoding);
}
+ public void endDocument() throws TransletException {
+ try {
+ // Close any open start tag
+ if (_startTagOpen) {
+ closeStartTag();
+ }
+
+ // Close output document
+ _saxHandler.endDocument();
+ }
+ catch (SAXException e) {
+ throw new TransletException(e);
+ }
+ }
+
+ /**
+ * Start an element in the output document. This might be an XML
+ * element (<elem>data</elem> type) or a CDATA section.
+ */
+ public void startElement(String elementName) throws TransletException {
+ try {
+ // Close any open start tag
+ if (_startTagOpen) {
+ closeStartTag();
+ }
+
+ // Handle document type declaration (for first element only)
+ if (_lexHandler != null) {
+ if ((_doctypeSystem != null) || (_doctypePublic != null))
+ _lexHandler.startDTD(elementName,
+ _doctypePublic,_doctypeSystem);
+ _lexHandler = null;
+ }
+
+ _depth++;
+ _elementName = elementName;
+ _attributes.clear();
+ _startTagOpen = true;
+ }
+ catch (SAXException e) {
+ throw new TransletException(e);
+ }
+ }
+
+ /**
+ * End an element or CDATA section in the output document
+ */
+ public void endElement(String elementName) throws TransletException {
+ try {
+ // Close any open element
+ if (_startTagOpen) {
+ closeStartTag();
+ }
+ _saxHandler.endElement(EMPTYSTRING, EMPTYSTRING, elementName);
+ }
+ catch (SAXException e) {
+ throw new TransletException(e);
+ }
+
+ }
+
public void attribute(String name, final String value)
throws TransletException
{
@@ -137,101 +198,16 @@
// Now is time to send the startElement event
_saxHandler.startElement(null, _elementName, _elementName,
_attributes);
-
- // Insert <META> tag directly after <HEAD> element in HTML output
- if (_headTagOpen) {
- emitHeader();
- _headTagOpen = false;
- }
}
catch (SAXException e) {
throw new TransletException(e);
}
}
-
- /**
- * Emit header through the SAX handler
- */
- private void emitHeader() throws SAXException {
- AttributeList attrs = new AttributeList();
- attrs.add("http-equiv", "Content-Type");
- attrs.add("content", _mediaType+"; charset="+_encoding);
- _saxHandler.startElement(EMPTYSTRING, EMPTYSTRING, "meta", attrs);
- _saxHandler.endElement(EMPTYSTRING, EMPTYSTRING, "meta");
- }
-
- /**
- * Start an element in the output document. This might be an XML
- * element (<elem>data</elem> type) or a CDATA section.
- */
- public void startElement(String elementName) throws TransletException {
- try {
- // Close any open start tag
- if (_startTagOpen) closeStartTag();
-
- // Handle document type declaration (for first element only)
- if (_lexHandler != null) {
- if ((_doctypeSystem != null) || (_doctypePublic != null))
- _lexHandler.startDTD(elementName,
- _doctypePublic,_doctypeSystem);
- _lexHandler = null;
- }
-
- _depth++;
- _elementName = elementName;
- _attributes.clear();
- _startTagOpen = true;
-
- // Insert <META> tag directly after <HEAD> element in HTML doc
- if (elementName.toLowerCase().equals("head")) {
- _headTagOpen = true;
- }
- } catch (SAXException e) {
- throw new TransletException(e);
- }
- }
-
- /**
- * End an element or CDATA section in the output document
- */
- public void endElement(String elementName) throws TransletException {
- try {
- // Close any open element
- if (_startTagOpen) {
- closeStartTag();
- }
- _saxHandler.endElement(EMPTYSTRING, EMPTYSTRING, elementName);
- }
- catch (SAXException e) {
- throw new TransletException(e);
- }
-
- }
-
/**
* Set the output media type - only relevant for HTML output
*/
public void setMediaType(String mediaType) {
- // This value does not have to be passed to the SAX handler. This
- // handler creates the HTML <meta> tag in which the media-type
- // (MIME-type) will be used.
_mediaType = mediaType;
- }
-
-
- /**
- * Ends the document output.
- */
- public void endDocument() throws TransletException {
- try {
- // Close any open start tag
- if (_startTagOpen) closeStartTag();
-
- // Close output document
- _saxHandler.endDocument();
- } catch (SAXException e) {
- throw new TransletException(e);
- }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org