public void handleStatement(Statement st)
throws RDFHandlerException
{
if (!writingStarted) {
throw new RDFHandlerException("Document writing has not yet been started");
}
try {
Resource context = st.getContext();
if (inActiveContext && !contextsEquals(context, currentContext)) {
// Close currently active context
xmlWriter.endTag(CONTEXT_TAG);
inActiveContext = false;
}
if (!inActiveContext) {
// Open new context
xmlWriter.startTag(CONTEXT_TAG);
if (context != null) {
writeValue(context);
}
currentContext = context;
inActiveContext = true;
}
xmlWriter.startTag(TRIPLE_TAG);
writeValue(st.getSubject());
writeValue(st.getPredicate());
writeValue(st.getObject());
xmlWriter.endTag(TRIPLE_TAG);
}
catch (IOException e) {
throw new RDFHandlerException(e);
}
}