History log of /libcore/xml/src/main/java/org/kxml2/io/KXmlParser.java
Revision Date Author Comments
0424d12f9b8a19c4a451282bc8ae974f6109424d 16-Oct-2013 Narayan Kamath <narayan@google.com> Get stricter about DOCTYPEs.

Allow them only before we've started parsing any
XML elements.

bug: 3452274
Change-Id: I7b146e4dae8c7aa23a0a227538ec02604f828400
9349ec01a1bebc3b704b400fb00ccfb42e047a02 27-Jun-2013 Vladimir Marko <vmarko@google.com> Fix unexpected EOF handling by KXmlParser.

Avoid read position slipping beyond limit on EOF, causing an
ArrayIndexOutOfBoundsException.

Also fix two incorrect checks whether to read more data.

Bug: 9012715
Change-Id: I40f60becd97eb4d9f33842bea2c19e9dc531d3b7
cff1616012dc0d56c2da9af2b9b1183e76c7e044 04-Dec-2012 Elliott Hughes <enh@google.com> Add detail messages to all the easy IllegalArgumentException cases.

Noticed during my recent Matcher change.

Change-Id: I415d911b26d0ee548ca04d56bba7fc3d4e6b3f88
6ce8e6ee5da964f724d39655fba0e432cff4c3a6 17-May-2011 Jesse Wilson <jessewilson@google.com> Skip BOM characters even with an explicit charset.

Change-Id: I697448528324cd68196d00ebf82ee8eecb72148d
http://code.google.com/p/android/issues/detail?id=16892
6aa068b481cc4cca7765ce90fdf32f3eb2b5a77c 18-Feb-2011 Elliott Hughes <enh@google.com> Fix various FindBugs warnings.

Only the ChunkHandler and ZoneInfo ones were real bugs. The former is only
called with one input value that doesn't exercise the bug, and the latter
would cause us to think that a time zone that stopped using daylight time
before 1970 was still using daylight time (which would defeat various
optimizations, but should otherwise be harmless).

The other stuff is trivia not worth individual changes.

Change-Id: Ib0752560cd16edc6538d1fc2b234451a66d48171
995a384234fd0ba9233ebcce380628bbe346b911 14-Feb-2011 Jesse Wilson <jessewilson@google.com> Fail parsing if there's text outside the document element.

We have a similar bug for misplaced DTDs. This is tested
but not fixed by this change.

Change-Id: I8e06ec9197cb8c4135212056ab791c254c9dcc3d
http://b/3452274
38e84b835c2101206d846f7ab6fc444914661753 20-Dec-2010 Jesse Wilson <jessewilson@google.com> Capture the DTD body while it is being parsed.

Change-Id: Ibef02ca759eb56a00f0f72f4063d129ef5350d21
http://b/3241492
866e7ae17a3da81a02b0b144e0c9c2b3196d293a 09-Dec-2010 Elliott Hughes <enh@google.com> Fix a bunch of javac -Xlint warnings in our code.

I think "fallthrough" uncovered a couple of real bugs in the kxml code, but
other than that there's nothing very exciting here. This addresses all but
one of the non-xml warnings. I'm assuming that we'll move the xml cruft out
into external at some point (since we're deliberately not maintaining it).

Change-Id: Ice81253b019df7b19d6557e719663b7bdc11fb22
773533775fab54079cebc329d54f6286f5ac16f2 30-Nov-2010 Jesse Wilson <jessewilson@google.com> The last of the Kxml correctness fixes for Expat compatibility.

With this change we should be able to drop the Expat pull parser
and use Kxml exclusively. I'm deferring that change until after
the current release.

Change-Id: I7c6d6dfe6c1e9ae9417c48603068ddd4ade78b76
http://b/3090550
086fd0244a54fa5ecf13ea66d49b22b36d7d456e 30-Nov-2010 Jesse Wilson <jessewilson@google.com> Fix XML DOM test failures and close guard warnings.

Fix KxmlParser to capture the DTD's root element name, system ID and
public ID. This is more robust than capturing the same in the pull-to-DOM
adapter.

Fix close guard warnings in XML tests. Close input streams of resource
files. Don't catch exceptions only to call fail().

http://b/3090550
Change-Id: I7cfafde58cc28af79c48386a4d124803c8791328
76c85883787791ba605a51d7bea3cfc27b5c5d95 25-Nov-2010 Jesse Wilson <jessewilson@google.com> Resolve entity values recursively and support default attributes.

Change-Id: Ib32040e0ebe8ef52e8d382fb65ab4d08779901b7
http://b/3090550
7fac047a67ee9a0295e4dc798c7c6880ccd83513 24-Nov-2010 Jesse Wilson <jessewilson@google.com> Implement DTD parsing in KxmlParser.

This change still has some problems:
- default attribute values are not honored.
- the doctype token text is lost
- entity values are not reparsed
- use of parameter entities is ignored but should cause a failure

Change-Id: Idd543846840aea481730e690e63212164555cdf1
http://b/3090550
bbf35ecae9bb5b69fb0d016a57a666d0a9e0f2fc 20-Nov-2010 Jesse Wilson <jessewilson@google.com> Change KxmlParser.next() to use one while loop instead of two.

This cleans up some of the structural problems with the KxmlParser code.
It was unclear how different text tokens (text, CDATA and entity tokens)
were concatenated in next() but not nextToken(). This moves the token loop
from the next() method into the nextImpl() method, saving redundant calls
to peekNext().

The code also had an instance field 'token' that was only well-defined
during calls to next() and nextToken(). I've removed this field and passed
parameters instead.

This fixes some implementation bugs:
- empty CDATA blocks aren't reported
- empty entities aren't reported
- double dash in comments are forbidden in strict mode <!-- -- -->

Change-Id: I8c17b61d63e84622556f3751dbf8af282c601d09
http://b/3090550
3b8cee4de39f9ff8199b4c1fd46cc8037fa45d15 19-Nov-2010 Jesse Wilson <jessewilson@google.com> Fix problems with entity references and relaxed namespaces.

Change-Id: I5c19ad97c98e6276129ed7228cc38d414b9517db
http://b/3090550
a78c2aac2a73f001aa00971adfae90af4d6726fb 14-Nov-2010 Jesse Wilson <jessewilson@google.com> Add interning to KxmlPullParser.

Adding just a small interning pool improves performance even further.
Combined with the first round of optimizations, total improvement for
three large files is 51% 56% and 42%. Performance on a small file
improved 3%. When interning is checked in, Kxml will be significantly
faster than Expat's pull parser for everything but very small files.

/sdcard/xml/com.amazon.mp3.meta /sdcard/xml/com.cooliris.picasa /sdcard/xml/com.rhapsody.Deauth /sdcard/xml/com.snoggdoggler.r
benchmark run us linear runtime % us linear runtime % us linear runtime % us linear runtime %
Dom baseline / master 210,256 ============================== 184% 53,227 ============================== 171% 2,183 ============================== 151% 164,708 ============================= 200%
Dom first optimizations 174,580 ======================== 153% 40,964 ======================= 132% 1,968 =========================== 136% 130,814 ======================= 159%
Dom new interning 163,366 ======================= 143% 35,736 ==================== 115% 2,116 ============================= 147% 121,870 ====================== 148%
ExpatPull baseline / master 130,078 ================== 114% 21,700 ============ 70% 759 ========== 53% 85,578 =============== 104%
ExpatPull first optimizations 129,776 ================== 114% 21,621 ============ 70% 734 ========== 51% 86,799 =============== 105%
ExpatPull new interning 130,971 ================== 115% 21,627 ============ 70% 723 ========= 50% 86,555 =============== 105%
KxmlPull baseline / master 114,317 ================ 100% 31,040 ================= 100% 1,443 =================== 100% 82,478 =============== 100%
KxmlPull first optimizations 88,716 ============ 78% 20,578 =========== 66% 1,560 ===================== 108% 58,567 ========== 71%
KxmlPull new interning 55,773 ======= 49% 13,692 ======= 44% 1,394 =================== 97% 48,068 ======== 58%

http://b/3090550
Change-Id: I4515546abbbcf940de7be22f26925c4334e59146
fda724de28fe86804e6ef6a0afd7ae5be1529083 05-Nov-2010 Jesse Wilson <jessewilson@google.com> Optimize KxmlParser.

I benchmarked this on four files:

size file
268 rhapsody authorization
29489 picasa sync (for gallery)
101129 amazon mp3 search results
103855 RSS feed

The performance regressed for the 268-byte file from 1.44ms to 1.56ms.
Small files are important and I intend to follow-up to bring this back
into line.

For the other files, the improvements for pull parsing were 22%, 34% and 29%.
Improvements for DOM parsing were 17%, 23% and 21%.

All but the 268-byte document now parse faster with Kxml than with Expat.

101129 byte amazon mp3 search results 29489 byte picasa sync dat 268 byte rhapsody authentication 103855 byte RSS feed
benchmark run us linear runtime us linear runtime us linear runtime us linear runtime
Dom ready to commit 174,580 ======================== 40,964 ======================= 1,968 =========================== 130,814 =======================
Dom baseline 210,256 ============================== 53,227 ============================== 2,183 ============================== 164,708 =============================
ExpatPull ready to commit 129,776 ================== 21,621 ============ 734 ========== 86,799 ===============
ExpatPull baseline 130,078 ================== 21,700 ============ 759 ========== 85,578 ===============
KxmlPull ready to commit 88,716 ============ 20,578 =========== 1,560 ===================== 58,567 ==========
KxmlPull baseline 114,317 ================ 31,040 ================= 1,443 =================== 82,478 ===============

Change-Id: I98b7f979c2f926e25c72541bf9f5036f097e8d91
http://b/3090550
ccd79e2bb784cdbd89e90a0e4301a707091d446d 04-Nov-2010 Jesse Wilson <jessewilson@google.com> Style cleanup of some XML code.

Motivation: in preparation to refactor the Kxml code I'd like
to bring this code to a style consistent with the rest of
Android. This code style currently disagrees with my toolchain.

Change-Id: Ibd24570c131e792532e46f7f44c64abac3a6979a
http://b/3090550
80a7fbab52b96c9fd47c72f8987d1babe2cd001d 22-May-2010 Elliott Hughes <enh@google.com> Remove more localized exception messages.

I also accidentally mixed two unrelated changes in here: replacing "".equals
and equals("") with String.isEmpty, and removing some dead code in
org.apache.harmony.luni.util.Util.

Change-Id: I0aaad43290b083085b3095b624caf096de487223
f33eae7e84eb6d3b0f4e86b59605bb3de73009f3 13-May-2010 Elliott Hughes <enh@google.com> Remove all trailing whitespace from the dalvik team-maintained parts of libcore.

Gentlemen, you may now set your editors to "strip trailing whitespace"...

Change-Id: I85b2f6c80e5fbef1af6cab11789790b078c11b1b
d21d78fd49a2d798218e8c8aefbddb26a0e71bbb 13-May-2010 Elliott Hughes <enh@google.com> Convert tabs to spaces.

Change-Id: I16cfbd2faac6b565b78b5dd97e2345323a36f652
1ec94feeb09591c30996c7c0834d6f131e204922 19-Feb-2010 Jesse Wilson <jessewilson@google.com> Filling in some gaps in our XML DOM v3 API.

Specifically, these methods on Node:
- setTextContent()
- isSameNode()
- lookupPrefix()
- lookupNamespaceURI()
In order to implement the last 2 I needed to fix our KXml parser
to include namespace attributes (ie. xmlns) in the pulled document.
Previously these were being elided.

Added a new testcase to verify our behaviour. It passes the RI. On
Dalvik we have a small issue with entity declarations.

Added a new testcase to verify Node.getBaseURI(). This test fails
because the method isn't implemented. Part of this test required
moving a method out to Support_Resources.java; in order to verify
the BaseURI the XML must be read from a file and not a stream (so
that path information exists).

Also...
- Style cleanup: changing static calls to look like static calls.
- Efficiency: avoiding concatenating with "" when unnecessary
- Duplication: sharing prefix validation between attributes and elements
- Renaming NodeTests to NodeTest for vogar-friendliness

Outstanding:
- I need to write a test for setTextContent().
6bcf32ab404c39b85d25430f6df16503ef3526cf 17-Nov-2009 Elliott Hughes <enh@google.com> Various XML fixes.

Add tests for bug 2487, exploring the situations where "]]>" is and isn't
allowed. Fix the bug by changing KXmlParser so it pays attention to
whether it's dealing with normal text or text in an attribute value and
reports errors appropriately.

In order to pass the new tests, we also need to fix DocumentBuilder to
pay attention to its DocumentBuilderFactory's "coalescing" setting: whether
or not adjacent text/CDATA nodes should be coalesced.

This in turn fixes a @KnownFailure in DocumentBuilderFactoryTest: previously
we didn't allow the caller to turn "coalescing" off (though until my
previous patch, we didn't actually coalesce anyway). Now we support both,
and I've made coalescing the default, because bug reports tell us that's
what users want. It's how the RI behaves, too.

Bug: 2487
b211e13cf03c07c92ba29829c581747ba0744767 10-Nov-2009 Elliott Hughes <enh@google.com> Bring our kxml2 up to date with upstream.

Much of this is spurious whitespace changes, but there's some increased
"relaxation". I deliberately lost the Android-specific change that was
avoiding Runtime, since we do now have Runtime. I've added an Android-specific
change to comment out some System.out logging that's been added upstream.

I'd tell you the upstream revision number, but they're still using CVS, so
there isn't one.
adc854b798c1cfe3bfd4c27d68d5cee38ca617da 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
1c0fed63c71ddb230f3b304aac12caffbedf2f21 04-Mar-2009 The Android Open Source Project <initial-contribution@android.com> auto import from //depot/cupcake/@135843
dd828f42a5c83b4270d4fbf6fce2da1878f1e84a 18-Dec-2008 The Android Open Source Project <initial-contribution@android.com> Code drop from //branches/cupcake/...@124589
fdb2704414a9ed92394ada0d1395e4db86889465 21-Oct-2008 The Android Open Source Project <initial-contribution@android.com> Initial Contribution