Hi Ryan,
There is an option when creating a parser to provide different policies
for generating the internal system identfier for a blank node.
RDFParser.create()..labelToNode(...)...
It shouldn't depend on JenaParameters.disableBNodeUIDGeneration but
there is a bug in the Turtle parser (JENA-2274) where it uses the core
blank node id allocator so you'll need teh global flag as well.
public static void main(String... args) {
// Blank nodes in [] and in an RDF collection (AKA list)
String s = "PREFIX : <http://example/> :s :p [ :q (1 2) ] .";
JenaParameters.disableBNodeUIDGeneration = true;
LabelToNode bnodes = LabelToNode.createIncremental();
StreamRDF output =
StreamRDFWriter.getWriterStream(System.out, Lang.NT);
RDFParser.create()
.fromString(s)
.lang(Lang.TTL)
.labelToNode(bnodes)
.parse(output);
}
The NT writer shows the label (it adds the "_:B")
Output at 4.4.0 (some URIs shortened to use in email).
_:BA100000 rdf:first "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:BA100000 rdf:rest _:BA100001 .
_:BA100001 rdf:first "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:BA100001 rdf:rest <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:BX400 <http://example/q> _:BA100000 .
<http://example/s> <http://example/p> _:BX400 .
There are two series of bnode here : BA100.. for lists and BX40.. for
other blank nodes.
That will change to something like:
_:B0001 rdf:first "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:B0001 rdf:rest _:B0002 .
_:B0002 rdf:first "2"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:B0002 rdf:rest <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
_:B0000 <http://example/q> _:B0001 .
<http://example/s> <http://example/p> _:B0000 .
and JenaParameters.disableBNodeUIDGeneration is not used when
https://issues.apache.org/jira/browse/JENA-2274
happens.
Andy
On 04/02/2022 21:20, Shaw, Ryan wrote:
On Feb 4, 2022, at 4:03 PM, Andy Seaborne <[email protected]> wrote:
Ryan,
Please, could you show example code that illustrates what you are seeing? Presumably it
isn't a mix in one parser run because it looks like "Annn" come from a
different place than UUIDs Ids.
--------------------------------------------------------------
package test;
import java.nio.file.Path;
import java.nio.file.Paths;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.riot.RDFDataMgr;
import org.apache.jena.shared.impl.JenaParameters;
public class Test {
public static void main(String[] args) {
JenaParameters.disableBNodeUIDGeneration = true;
Path path = Paths.get(args[0]);
Model model = RDFDataMgr.loadModel(path.toString());
model.getGraph().stream().forEach(System.out::println);
}
}
--------------------------------------------------------------
When I run the above on the following input:
--------------------------------------------------------------
PREFIX :
<https://periodo.github.io/edtf-ontology/cases/level-2/range/on-or-after/>
PREFIX iso8601: <http://www.opengis.net/def/uom/ISO-8601/0/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX time: <http://www.w3.org/2006/time#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
:when1
a [
a owl:Class ;
owl:equivalentClass [
owl:intersectionOf (
time:Instant
[
a owl:Restriction ;
owl:allValuesFrom [
owl:unionOf (
[
owl:intersectionOf (
time:DateTimeDescription
[
a owl:Restriction ;
owl:onProperty time:year ;
owl:someValuesFrom [
a rdfs:Datatype ;
owl:onDatatype xsd:integer ;
owl:withRestrictions (
[
xsd:minInclusive 1984
]
)
]
]
)
]
[
owl:intersectionOf (
time:GeneralDateTimeDescription
[
owl:complementOf [
a owl:Restriction ;
owl:hasValue iso8601:Gregorian ;
owl:onProperty time:hasTRS
]
]
)
]
)
] ;
owl:onProperty time:inDateTime
]
)
]
] ;
rdfs:label "1984 or some later year" ;
.
--------------------------------------------------------------
I get:
--------------------------------------------------------------
231b263db2bfddb58dfa9937b3b7c3a0 @owl:withRestrictions A100002
231b263db2bfddb58dfa9937b3b7c3a0 @owl:onDatatype xsd:integer
231b263db2bfddb58dfa9937b3b7c3a0 @rdf:type rdfs:Datatype
8c6c72efd28cd325bc71b79a849faaa1 @xsd:minInclusive
"1984"^^http://www.w3.org/2001/XMLSchema#integer
A100004 @rdf:rest A100007
A100004 @rdf:first 820826bd52ee5a08eb7622801e144c6e
https://periodo.github.io/edtf-ontology/cases/level-2/range/on-or-after/when1 @rdfs:label
"1984 or some later year"
https://periodo.github.io/edtf-ontology/cases/level-2/range/on-or-after/when1
@rdf:type 132cb499d890d8900be00c8642b044d4
A100003 @rdf:rest rdf:nil
A100003 @rdf:first faf2ba604cbef59a8f51d8c9242632f3
A100008 @rdf:rest rdf:nil
A100008 @rdf:first 5fdb8fff2b57077c0eeb04c51a5c81f9
132cb499d890d8900be00c8642b044d4 @owl:equivalentClass
f36891f02e7b41fedf7ff3f1328aa1a5
132cb499d890d8900be00c8642b044d4 @rdf:type owl:Class
A100002 @rdf:rest rdf:nil
A100002 @rdf:first 8c6c72efd28cd325bc71b79a849faaa1
ce14b1c198fa8523fcc9cd87b6675ed7 @owl:onProperty
http://www.w3.org/2006/time#hasTRS
ce14b1c198fa8523fcc9cd87b6675ed7 @owl:hasValue
http://www.opengis.net/def/uom/ISO-8601/0/Gregorian
ce14b1c198fa8523fcc9cd87b6675ed7 @rdf:type owl:Restriction
faf2ba604cbef59a8f51d8c9242632f3 @owl:someValuesFrom
231b263db2bfddb58dfa9937b3b7c3a0
faf2ba604cbef59a8f51d8c9242632f3 @owl:onProperty
http://www.w3.org/2006/time#year
faf2ba604cbef59a8f51d8c9242632f3 @rdf:type owl:Restriction
7689913c074aeda41f891ce04e89887f @owl:complementOf
ce14b1c198fa8523fcc9cd87b6675ed7
5fdb8fff2b57077c0eeb04c51a5c81f9 @owl:onProperty
http://www.w3.org/2006/time#inDateTime
5fdb8fff2b57077c0eeb04c51a5c81f9 @owl:allValuesFrom
ed7e04ca589571c4721e5fff308d1fb3
5fdb8fff2b57077c0eeb04c51a5c81f9 @rdf:type owl:Restriction
A100001 @rdf:rest A100003
A100001 @rdf:first http://www.w3.org/2006/time#DateTimeDescription
A100007 @rdf:rest rdf:nil
A100007 @rdf:first ae601ad87efaaa77cb1e8d3dd1eec259
ed7e04ca589571c4721e5fff308d1fb3 @owl:unionOf A100004
ae601ad87efaaa77cb1e8d3dd1eec259 @owl:intersectionOf A100005
A100000 @rdf:rest A100008
A100000 @rdf:first http://www.w3.org/2006/time#Instant
A100006 @rdf:rest rdf:nil
A100006 @rdf:first 7689913c074aeda41f891ce04e89887f
820826bd52ee5a08eb7622801e144c6e @owl:intersectionOf A100001
f36891f02e7b41fedf7ff3f1328aa1a5 @owl:intersectionOf A100000
A100005 @rdf:rest A100006
A100005 @rdf:first http://www.w3.org/2006/time#GeneralDateTimeDescription
--------------------------------------------------------------
Which version of Jena are you running?
4.4.0