Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xerces on Android

Tags:

android

I found several references in the mailinglist archive about Xerces, but it is still not clear to me if it is possible use Xerces succesfully in Android. Could you please provide me this information?

If the answer is Yes, could you please give me some tips or references on how use Xerces instead of default Android XML parser?

Thanks in advance for your support

kind regards Barbara

like image 950
Barbara Avatar asked Apr 16 '10 09:04

Barbara


People also ask

What is Xerces jar used for?

In computing, Xerces is Apache's collection of software libraries for parsing, validating, serializing and manipulating XML. The library implements a number of standard APIs for XML parsing, including DOM, SAX and SAX2. The implementation is available in the Java, C++ and Perl programming languages.

Is Xerces open source?

The Xerces-C++ source code is stored in the Apache Git repository. The repository is public and everyone has read access.


3 Answers

Xerces extends the core library javax which leads to this problem in Android (mentioned by @Avi Cherry).

You can overcome this problem by repackaging the needed classes with a tool like JarJar. This has been done in the Xerces-for-Android, wherein the package mf is placed above the "normal" Xerces packages.

like image 75
Petterson Avatar answered Oct 02 '22 08:10

Petterson


You can check out Androjena; it's a porting of Jena to the Android platform, and it uses Android's built-in XML parsers instead of Xerces. Hope this helps, bye!

like image 28
lencinhaus Avatar answered Oct 02 '22 10:10

lencinhaus


While you -can- include Xerces in your project, you need to add the --core-library command-line option to the dex tool. But you shouldn't do this, because when the javax/xml/parsers/DocumentBuilder.class class (for example) IS finally supported by an SDK version, your application will likely break. Instead, you should probably use the jarjar utility to re-package xerces into a self-contained library with unique package names.

Note that the error message that 'dex' gives you if you include a java or javax package WITHOUT the --core-library option, involves the phrase:

the path you are on will ultimately lead to pain, suffering, grief, and lamentation.

The same error message also suggests that you use JarJar to repackage the library.

like image 26
Avi Cherry Avatar answered Oct 02 '22 08:10

Avi Cherry