aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
diff options
context:
space:
mode:
authorGravatar Googler <noreply@google.com>2016-07-11 19:55:04 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2016-07-12 11:17:51 +0000
commitc41b10c728e9752beb65b7db5d997fb9d01b7640 (patch)
tree42f6d81d7d6991591ebbcd2a65563da6559a6bab /src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
parent84ecac51d43fe4dba262740f4ddb3826bea4bb17 (diff)
Centralize the creation of the XmlInputFactory
Properly handle unary tags in AttrXmlResourceValue Handle CData for string content. -- MOS_MIGRATED_REVID=127118005
Diffstat (limited to 'src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java')
-rw-r--r--src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
index 5876966239..c154a196ff 100644
--- a/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
+++ b/src/tools/android/java/com/google/devtools/build/android/XmlResourceValues.java
@@ -44,6 +44,7 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
@@ -84,6 +85,17 @@ public class XmlResourceValues {
static final String XLIFF_NAMESPACE = "urn:oasis:names:tc:xliff:document:1.2";
static final String XLIFF_PREFIX = "xliff";
+
+ private static XMLInputFactory inputFactoryInstance = null;
+ public static XMLInputFactory getXmlInputFactory() {
+ if (inputFactoryInstance == null) {
+ inputFactoryInstance = XMLInputFactory.newInstance();
+ inputFactoryInstance.setProperty(
+ "http://java.sun.com/xml/stream/properties/report-cdata-event", Boolean.TRUE);
+ }
+ return inputFactoryInstance;
+ }
+
static XmlResourceValue parsePlurals(XMLEventReader eventReader) throws XMLStreamException {
ImmutableMap.Builder<String, String> values = ImmutableMap.builder();
for (XMLEvent element = nextTag(eventReader);
@@ -239,7 +251,7 @@ public class XmlResourceValues {
StringWriter contents = new StringWriter();
XMLEventWriter writer = XML_OUTPUT_FACTORY.createXMLEventWriter(contents);
while (!isEndTag(eventReader.peek(), startTag)) {
- XMLEvent xmlEvent = eventReader.nextEvent();
+ XMLEvent xmlEvent = (XMLEvent) eventReader.next();
if (xmlEvent.isStartElement()) {
// TODO(corysmith): Replace this with a proper representation of the contents that can be
// serialized and reconstructed appropriately without modification.