Closed vuras closed 2 months ago
Hi,
The org.apache.jena.graph.NodeFactory
still offers plenty of ways to create literals.
Which kind of literal do you want to create?
Arne
rdf:parseType="Literal"
is the RDF/XML form syntax.
It may not get written out using rdf:parseType="Literal"
because that only happens if the value is valid for the rdf:XMLLiteral
value space. Otherwise, it will be written with rdf:datatype
and a string with escaped XML characters.
Jena 5.1.0 supports the RDF 1.1 definition of the value space. While simpler than the RDF 1.0 definition of exclusive canonicalization, it still quite complicated.
https://www.w3.org/TR/rdf11-concepts/#section-XMLLiteral
Either way of writing is the same RDF term.
NodeFactory
:
NodeFactory.createLiteralDT(String, RDF.dtXMLLiteral)`.
RDF.dtXMLLiteral
is an RDFDatatype
.
and for Model
:
Literal createTypedLiteral(String lex, RDF.dtXMLLiteral);
Hi everyone,
Thank you for the answers.
I managed to find the solution myself before reading your answers.
Looks similar to what afs proposed:
Literal createTypedLiteral(String lex, XMLLiteralType.theXMLLiteralType);
@vuras - Glad to hear you found it.
RDF.dtXMLLiteral
and XMLLiteralType.theXMLLiteralType
are the same constant.
RDF.dtXMLLiteral
is slightly better to use.
XMLLiteralType.theXMLLiteralType
isn't a good name because nothing else is "the...". It really ought to be be migrated to more normal name.
Version
5.1.0
Question
Hi,
As this method was deprecated and is removed in version 5.1.0:
@Deprecated public Literal createLiteral(String v, boolean wellFormed);
How should I add a rdf:parseType="Literal" to any Property?