Hi all,
It seems it is impossible to use the BIO serializer/deserializer with
data which are not retrieved from a dataset.
Hereafter is a simple usecase:
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Binding b = BindingFactory.create();
b.add(Var.alloc("test"), Node.createLiteral("21", XSDDatatype.XSDint));
BindingOutputStream bos = new BindingOutputStream(baos);
bos.write(b);
bos.close();
BindingInputStream bis =
new BindingInputStream(new ByteArrayInputStream(
baos.toByteArray()));
System.out.println(bis.next());
When I try to serialize a binding which contains a Node annotated as
XSDDatatype.XSD*basicType* (e.g. XSDDatatype.XSDint,
XSDDatatype.XSDlong), I get:
Exception in thread "main" org.openjena.riot.RiotException: [line: 2,
col: 7 ] Undefined prefix: xsd
at
org.openjena.riot.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:110)
at
org.openjena.riot.system.ParserProfileBase.expandPrefixedName(ParserProfileBase.java:209)
at
org.openjena.riot.system.ParserProfileBase.create(ParserProfileBase.java:173)
at
com.hp.hpl.jena.sparql.engine.binding.BindingInputStream$IteratorTuples.moveToNext(BindingInputStream.java:194)
at
com.hp.hpl.jena.sparql.engine.binding.BindingInputStream$IteratorTuples.moveToNext(BindingInputStream.java:139)
at
org.openjena.atlas.iterator.IteratorSlotted.hasNext(IteratorSlotted.java:55)
at
org.openjena.atlas.iterator.IteratorSlotted.next(IteratorSlotted.java:64)
at
com.hp.hpl.jena.sparql.engine.binding.BindingInputStream.next(BindingInputStream.java:129)
However, when XSDDatatype.XSDinteger is used it works. Indeed, if I
have understood, data which are inserted into a dataset with tags
XSDDatatype.XSDint or XSDDatatype.XSDlong are automatically translated
to XSDDatatype.XSDinteger which uses an arbitrary precision. Is it not
possible to adapt the RIOT parser to accept default XSD types?
Kind Regards,
Laurent