
For my master's thesis I needed a way to parse my ontology which was saved as an OWL file. There are a lot of XML parsers for J2ME but there was no parser available for RDF or OWL files.
So I used the the NanoXML parser for J2ME by
Eric Giguere which is based on the parser of
Marc De Scheemaecker and modified it. NanoXML is a model parser.
I added the class kRDFElement. It is based on the kXMLElement class and I added some useful fields and methods to parse and change RDF and OWL files comfortably. Note that if you use Protégé to create an OWL file, save it as "RDF/XML" and not "RDF/XML-ABBREV".
Head over to the
Sourceforge-Page of NanoXML for J2ME for the library and the source files.
The most important changes are:
Some
static constants were added, who are RDF/OWL specific:
-RDF_DESCRIPTION
-RDF_ABOUT
-RDF_ID
-RDF_RESOURCE
-RDF_TYPE
Some methods are used to
get information from the current kRDFElement (see figure).
-getAboutValue
-getContenstOfSubtag(String tagName)
-getResourceValueOfSubtag(String tagName)
-getTypeName()
Some methods are used to
change the kRDFElement
-setAboutValue(String aboutValue)
-setResourceValue(String resourceId)
And there are also two very handy methods who
search in the kRDFElement for kRDFElements. They are most useful when applied to the root-kRDFElement of the whole OWL-file.
-searchForElement(String rdfAboutValue) - returns the kRDFElement with the given rdfAboutValue
-searchForAllElementsOfType(String rdfAboutValue,String elementTypeName) - returns all the kRDFElements of the given type
If you are not restricted to a J2ME environment it is easier to use a RDF/OWL framework or API like
Jena Semantic Web Framework.