use of org.xml.sax.ext.Locator2 in project spring-framework by spring-projects.
the class StaxStreamXMLReader method handleStartDocument.
private void handleStartDocument() throws SAXException {
if (XMLStreamConstants.START_DOCUMENT == this.reader.getEventType()) {
String xmlVersion = this.reader.getVersion();
if (StringUtils.hasLength(xmlVersion)) {
this.xmlVersion = xmlVersion;
}
this.encoding = this.reader.getCharacterEncodingScheme();
}
if (getContentHandler() != null) {
final Location location = this.reader.getLocation();
getContentHandler().setDocumentLocator(new Locator2() {
@Override
public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1);
}
@Override
public int getLineNumber() {
return (location != null ? location.getLineNumber() : -1);
}
@Override
public String getPublicId() {
return (location != null ? location.getPublicId() : null);
}
@Override
public String getSystemId() {
return (location != null ? location.getSystemId() : null);
}
@Override
public String getXMLVersion() {
return xmlVersion;
}
@Override
public String getEncoding() {
return encoding;
}
});
getContentHandler().startDocument();
if (this.reader.standaloneSet()) {
setStandalone(this.reader.isStandalone());
}
}
}
use of org.xml.sax.ext.Locator2 in project camel by apache.
the class StaxStreamXMLReader method handleStartDocument.
private void handleStartDocument() throws SAXException {
if (XMLStreamConstants.START_DOCUMENT == reader.getEventType()) {
String xmlVersion = reader.getVersion();
if (ObjectHelper.isNotEmpty(xmlVersion)) {
this.xmlVersion = xmlVersion;
}
this.encoding = reader.getCharacterEncodingScheme();
}
if (getContentHandler() != null) {
final Location location = reader.getLocation();
getContentHandler().setDocumentLocator(new Locator2() {
public int getColumnNumber() {
return location != null ? location.getColumnNumber() : -1;
}
public int getLineNumber() {
return location != null ? location.getLineNumber() : -1;
}
public String getPublicId() {
return location != null ? location.getPublicId() : null;
}
public String getSystemId() {
return location != null ? location.getSystemId() : null;
}
public String getXMLVersion() {
return xmlVersion;
}
public String getEncoding() {
return encoding;
}
});
getContentHandler().startDocument();
if (reader.standaloneSet()) {
setStandalone(reader.isStandalone());
}
}
}
use of org.xml.sax.ext.Locator2 in project spring-framework by spring-projects.
the class StaxEventXMLReader method handleStartDocument.
private void handleStartDocument(final XMLEvent event) throws SAXException {
if (event.isStartDocument()) {
StartDocument startDocument = (StartDocument) event;
String xmlVersion = startDocument.getVersion();
if (StringUtils.hasLength(xmlVersion)) {
this.xmlVersion = xmlVersion;
}
if (startDocument.encodingSet()) {
this.encoding = startDocument.getCharacterEncodingScheme();
}
}
if (getContentHandler() != null) {
final Location location = event.getLocation();
getContentHandler().setDocumentLocator(new Locator2() {
@Override
public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1);
}
@Override
public int getLineNumber() {
return (location != null ? location.getLineNumber() : -1);
}
@Override
public String getPublicId() {
return (location != null ? location.getPublicId() : null);
}
@Override
public String getSystemId() {
return (location != null ? location.getSystemId() : null);
}
@Override
public String getXMLVersion() {
return xmlVersion;
}
@Override
public String getEncoding() {
return encoding;
}
});
getContentHandler().startDocument();
}
}
Aggregations