Lightweight RDFa Parser in Java
contact: Fabien.Gandon@sophia.inria.fr
Versions
This parser is available as freeware and under the non viral open-source licence
CeCILL-C. It uses Java 1.6 and works only with well-formed XHTML documents
Instructions
Command line
To use it in command mode: java -jar RDFaParser-0.0.6.jar e.g.
java -jar RDFaParser-0.0.6.jar http://www.w3.org/2006/07/SWD/RDFa/testsuite/xhtml1-testcases/1001.xhtml
API
To use it in a java application this short example is the best documentation:
|
import fr.inria.rdfa.RDFaParser;
import java.io.IOException;
import java.io.Reader;
import javax.xml.transform.TransformerConfigurationException;
import javax.xml.transform.TransformerException;
...
// Get a parser
RDFaParser aParser = new RDFaParser()
{
public void handleDataProperty(String subjectURI, String subjectNodeID,
String propertyURI, String value, String datatype, String lang) {
... // handle the Data property event
}
public void handleObjectProperty(String subjectURI, String subjectNodeID,
String propertyURI, String objectURI, String objectNodeID) {
... // handle the Object property event
}
};
...
Reader aReader = null; // replace this by a reader on the source
String aBase = null; // base or URL of the source
try {
aParser.parse(aReader, aBase);
} catch (TransformerConfigurationException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TransformerException e) {
e.printStackTrace();
} |