use of org.qi4j.library.rdf.serializer.RdfXmlSerializer in project qi4j-sdk by Qi4j.
the class EntitySerializerTest method testEntitySerializer.
@Test
public void testEntitySerializer() throws RDFHandlerException {
EntityReference entityReference = new EntityReference("test2");
EntityState entityState = entityStore.newUnitOfWork(UsecaseBuilder.newUsecase("Test"), module, System.currentTimeMillis()).entityStateOf(entityReference);
Iterable<Statement> graph = serializer.serialize(entityState);
String[] prefixes = new String[] { "rdf", "dc", " vc" };
String[] namespaces = new String[] { Rdfs.RDF, DcRdf.NAMESPACE, "http://www.w3.org/2001/vcard-rdf/3.0#" };
new RdfXmlSerializer().serialize(graph, new PrintWriter(System.out), prefixes, namespaces);
}
use of org.qi4j.library.rdf.serializer.RdfXmlSerializer in project qi4j-sdk by Qi4j.
the class EntityTypeSerializerTest method testEntityTypeSerializer.
@Test
public void testEntityTypeSerializer() throws RDFHandlerException {
EntityDescriptor entityDescriptor = module.entityDescriptor(TestEntity.class.getName());
Iterable<Statement> graph = serializer.serialize(entityDescriptor);
String[] prefixes = new String[] { "rdf", "dc", " vc", "qi4j" };
String[] namespaces = new String[] { Rdfs.RDF, DcRdf.NAMESPACE, "http://www.w3.org/2001/vcard-rdf/3.0#", Qi4jEntityType.NAMESPACE };
new RdfXmlSerializer().serialize(graph, new PrintWriter(System.out), prefixes, namespaces);
}
use of org.qi4j.library.rdf.serializer.RdfXmlSerializer in project qi4j-sdk by Qi4j.
the class EntityResource method representRdfXml.
private Representation representRdfXml(final EntityState entity) throws ResourceException {
Representation representation = new WriterRepresentation(MediaType.APPLICATION_RDF_XML) {
@Override
public void write(Writer writer) throws IOException {
try {
Iterable<Statement> statements = entitySerializer.serialize(entity);
new RdfXmlSerializer().serialize(statements, writer);
} catch (RDFHandlerException e) {
throw new IOException(e);
}
}
};
representation.setCharacterSet(CharacterSet.UTF_8);
return representation;
}
Aggregations