You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (Jira)" <ji...@apache.org> on 2021/02/07 10:05:00 UTC
[jira] [Comment Edited] (JENA-2026) Incorrectly namespacing of
objects in XML - xmlns:j.0
[ https://issues.apache.org/jira/browse/JENA-2026?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17269363#comment-17269363 ]
Andy Seaborne edited comment on JENA-2026 at 2/7/21, 10:04 AM:
---------------------------------------------------------------
The data seems to have been copied from a wiki. It's quite mangled text; I hope the read data does not have [ ] in URIs.
The Turtle and RDF/XML don't agree - where is "xmlns:ex4" for the RDF/XML? I parsed the Turtle and got:
{noformat}
xmlns:ex4="http://example4.org/ontology/ex4#"
{noformat}
and the RDF/XML example has uses of ex4 which must come from somewhere.
I'm still guessing what your code is doing. The example has data but not how you handle it.
----
The RDF/XML output seems to have been written by the RDF/XML basic writer.
The "pretty" writer (RDFXML-ABBREV or the default to RDFDataMgr.write) will use the j.0 prefix. It uses this to write the class in abbreviate form in an XML tag. See example below.
----
Example URI: {{http://example/a#b/c}} -- the significant point is the {{/}} in the fragment {{#b/c}} -- and this prefix {{ex:}} {{http://example/a#}}.
An XML qname can not have a "/" in it. We can not write XML tag: {{<ex:b/c>.... </ex:b/c>}}.
So (RDF/XML pretty form), Jena generates {{xmlns:j.0="http://example2/a#b/}} and can then write {{<j.0:c>}} for the class.
I don't know why the basic writer generates the "j.0" - it may be being defensive; it does not change the meaning of the data.
Properties must be written using XML tags; classes are optionally written as XML tags. In the example below see {{<j.0:p>}},because "ex2:" can not be used.
{noformat}
public static void main(String... a) throws Exception {
String x = FileUtils.readWholeFileAsUTF8("/home/afs/tmp/D.ttl");
System.out.println("---- Data");
System.out.print(x);
System.out.println("---- Turtle");
Model m = RDFDataMgr.loadModel("/home/afs/tmp/D.ttl");
RDFDataMgr.write(System.out, m, RDFFormat.TURTLE_PRETTY);
System.out.println("---- RDF/XML Pretty");
RDFDataMgr.write(System.out, m, RDFFormat.RDFXML_PRETTY);
System.out.println("---- RDF/XML Basic");
RDFDataMgr.write(System.out, m, RDFFormat.RDFXML_PLAIN);
System.exit(0);
}
{noformat}
{noformat}
---- Data
PREFIX : <http://example/>
PREFIX ex2: <http://example2/a#>
:x a <http://example2/a#b/c> .
:z <http://example2/a#b/p> "123" .
---- Turtle
PREFIX : <http://example/>
PREFIX ex2: <http://example2/a#>
:z <http://example2/a#b/p> "123" .
:x a <http://example2/a#b/c> .
---- RDF/XML Pretty
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example/"
xmlns:ex2="http://example2/a#"
xmlns:j.0="http://example2/a#b/">
<j.0:c rdf:about="http://example/x"/>
<rdf:Description rdf:about="http://example/z">
<j.0:p>123</j.0:p>
</rdf:Description>
</rdf:RDF>
---- RDF/XML Basic
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example/"
xmlns:ex2="http://example2/a#"
xmlns:j.0="http://example2/a#b/" >
<rdf:Description rdf:about="http://example/x">
<rdf:type rdf:resource="http://example2/a#b/c"/>
</rdf:Description>
<rdf:Description rdf:about="http://example/z">
<j.0:p>123</j.0:p>
</rdf:Description>
</rdf:RDF>
{noformat}
was (Author: andy.seaborne):
The data seems to have been copied from a wiki. It's quite mangled text; I hope the read data does not have [ ] in URIs.
The Turtle and RDF/XML don't agree - where is "xmlns:ex4" for the RDF/XML? I parsed the Turtle and got:
{{ xmlns:ex4="http://example4.org/ontology/ex4#"}}
and the RDF/XML example has uses of ex4 which must come from somewhere.
I'm still guessing what your code is doing. The example has data but not how you handle it.
----
The RDF/XML output seems to have been written by the RDF/XML basic writer.
The "pretty" writer (RDFXML-ABBREV or the default to RDFDataMgr.write) will use the j.0 prefix. It uses this to write the class in abbreviate form in an XML tag. See example below.
----
Example URI: {{http://example/a#b/c}} -- the significant point is the {{/}} in the fragment {{#b/c}} -- and this prefix {{ex:}} {{http://example/a#}}.
An XML qname can not have a "/" in it. We can not write XML tag: {{<ex:b/c>.... </ex:b/c>}}.
So (RDF/XML pretty form), Jena generates {{xmlns:j.0="http://example2/a#b/}} and can then write {{<j.0:c>}} for the class.
I don't know why the basic writer generates the "j.0" - it may be being defensive; it does not change the meaning of the data.
Properties must be written using XML tags; classes are optionally written as XML tags. In the example below see {{<j.0:p>}},because "ex2:" can not be used.
{noformat}
public static void main(String... a) throws Exception {
String x = FileUtils.readWholeFileAsUTF8("/home/afs/tmp/D.ttl");
System.out.println("---- Data");
System.out.print(x);
System.out.println("---- Turtle");
Model m = RDFDataMgr.loadModel("/home/afs/tmp/D.ttl");
RDFDataMgr.write(System.out, m, RDFFormat.TURTLE_PRETTY);
System.out.println("---- RDF/XML Pretty");
RDFDataMgr.write(System.out, m, RDFFormat.RDFXML_PRETTY);
System.out.println("---- RDF/XML Basic");
RDFDataMgr.write(System.out, m, RDFFormat.RDFXML_PLAIN);
System.exit(0);
}
{noformat}
{noformat}
---- Data
PREFIX : <http://example/>
PREFIX ex2: <http://example2/a#>
:x a <http://example2/a#b/c> .
:z <http://example2/a#b/p> "123" .
---- Turtle}}.
PREFIX : <http://example/>
PREFIX ex2: <http://example2/a#>
:z <http://example2/a#b/p> "123" .
:x a <http://example2/a#b/c> .
---- RDF/XML Pretty
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example/"
xmlns:ex2="http://example2/a#"
xmlns:j.0="http://example2/a#b/">
<j.0:c rdf:about="http://example/x"/>
<rdf:Description rdf:about="http://example/z">
<j.0:p>123</j.0:p>
</rdf:Description>
</rdf:RDF>
---- RDF/XML Basic
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example/"
xmlns:ex2="http://example2/a#"
xmlns:j.0="http://example2/a#b/" >
<rdf:Description rdf:about="http://example/x">
<rdf:type rdf:resource="http://example2/a#b/c"/>
</rdf:Description>
<rdf:Description rdf:about="http://example/z">
<j.0:p>123</j.0:p>
</rdf:Description>
</rdf:RDF>
{noformat}
> Incorrectly namespacing of objects in XML - xmlns:j.0
> -----------------------------------------------------
>
> Key: JENA-2026
> URL: https://issues.apache.org/jira/browse/JENA-2026
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 3.13.0
> Reporter: Shirley Tarboton
> Priority: Minor
>
> When we use ClassOf... objects (PowerTypes) the RDF file contains spurious namespaces e.g. {color:#de350b}*xmlns:j.0*{color}="[http://....//#] ClassOf ...."
> This happens even when we have already added a namespace using NSPrefix
--
This message was sent by Atlassian Jira
(v8.3.4#803005)