< prev index next >
src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/SAX2StAXBaseWriter.java
Print this page
*** 1,8 ****
/*
! * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
! * @LastModified: Oct 2017
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 34,61 ****
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.ext.LexicalHandler;
import org.xml.sax.helpers.DefaultHandler;
-
public abstract class SAX2StAXBaseWriter extends DefaultHandler
implements
LexicalHandler {
-
protected boolean isCDATA;
protected StringBuffer CDATABuffer;
protected List<String> namespaces;
protected Locator docLocator;
protected XMLReporter reporter;
public SAX2StAXBaseWriter() {
}
public SAX2StAXBaseWriter(XMLReporter reporter) {
this.reporter = reporter;
--- 33,61 ----
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import org.xml.sax.ext.LexicalHandler;
+ import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.DefaultHandler;
public abstract class SAX2StAXBaseWriter extends DefaultHandler
implements
LexicalHandler {
protected boolean isCDATA;
protected StringBuffer CDATABuffer;
protected List<String> namespaces;
protected Locator docLocator;
protected XMLReporter reporter;
+ String xmlVersion = null, encoding = null;
+
public SAX2StAXBaseWriter() {
}
public SAX2StAXBaseWriter(XMLReporter reporter) {
this.reporter = reporter;
*** 67,84 ****
public void setDocumentLocator(Locator locator) {
this.docLocator = locator;
}
public Location getCurrentLocation() {
if (docLocator != null) {
return new SAXLocation(docLocator);
} else {
return null;
}
-
}
public void error(SAXParseException e) throws SAXException {
reportException("ERROR", e);
}
--- 67,102 ----
public void setDocumentLocator(Locator locator) {
this.docLocator = locator;
}
+ private void updateVersionAndEncoding() {
+ if (docLocator instanceof Locator2) {
+ Locator2 l2 = (Locator2) docLocator;
+ xmlVersion = l2.getXMLVersion();
+ encoding = l2.getEncoding();
+ }
+ }
+
+ public void setXmlVersion(String version) {
+ this.xmlVersion = version;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
+
+ void writeStartDocument() throws SAXException {
+ updateVersionAndEncoding();
+ }
public Location getCurrentLocation() {
if (docLocator != null) {
return new SAXLocation(docLocator);
} else {
return null;
}
}
public void error(SAXParseException e) throws SAXException {
reportException("ERROR", e);
}
*** 123,133 ****
}
namespaces.add(prefix);
namespaces.add(uri);
}
-
public void endPrefixMapping(String prefix) throws SAXException {
}
public void startCDATA() throws SAXException {
isCDATA = true;
--- 141,150 ----
< prev index next >