Porting Techniques
If you do decide to port one of the parsers that doesn't build in MIDP out of the box, there are several techniques you may wish to consider:
-
Dump features you don't need. If the parser code is modularized well, you may be able to remove entire subdirectories of the source code, assuming you don't need those features in your application. You might, for example, be able to drop off a package that puts a SAX interface on top of the parser or a WAP support package.
-
Parsers often won't compile because they use classes from J2SE that aren't present in MIDP. One way to fix this is to supply the missing J2SE classes. There are two challenges with this approach. First, there are legal restrictions on the use of J2SE source code. See the source license for the full details. You can work around this by supplying your own implementation. The second problem is that MIDP implementations won't load classes defined in the java.* and javax.* namespaces. You can work around this problem using an obfuscator that renames the classes into different packages. (Chapter 15 has some more details on this.)
-
A cleaner option is to use classes in the same package or inner classes to replace the missing pieces of J2SE.