I'm not sure that thinking in terms of "declarations" and "references"
is helpful here. rdf:about is a normal way to state the subject of a
statement, rdf:id is an optional abbreviation of it:
"The rdf:ID attribute on a node element (not property element, that has
another meaning) can be used instead of rdf:about ..." [1]
The thing with rdf:ID is that you are only allowed one rdf:ID with a
given name in each document and so you have to keep track of whether you
have already used that form (and if you then then use rdf:about
everywhere else). Whereas you can use rdf:about on the same URI
(including relative URI) as often as you like.
[This has nothing directly to do with circularity of cross referencing.
When you refer to a resource you are using it as the object of a
statement which in RDF/XML means using the rdf:resource attribute.]
If you want to be certain of a "flat" structure then use rdf:about
uniformly, rather than use rdf:id uniformly. You can do that by using
the non-ABBREV writer or by switching off the rdf:id option in the
ABBREV writer (see the Block rules section of 2). You can't turn off
rdf:about as far as I know, that would be problematic.
If your consuming application *really* requires only rdf:ID and not
rdf:about and you really can't get that changed then your best bet
*might* be to use the non-ABBREV writer to get simple flat XML that you
then transform yourself to meet the custom syntactic constraints of your
consumer.
Dave
[1] http://www.w3.org/TR/rdf-syntax-grammar/#section-Syntax-ID-xml-base
[2]
http://jena.apache.org/documentation/io/rdfxml_howto.html#advanced-rdfxml-output
On 02/09/13 13:54, Nis Jespersen wrote:
Dear [email protected],
I am currently working on producing an RDF XML file with a bunch of high
voltage electrical objects in it. I've come a long way, but recently hit
an obstacle because three classes are referencing each other circularly.
Basically, a ShuntCompensator references a RegulatingControl which
references a Terminal which references a ShuntCompensator - and the circle
is thus completed.
It is no problem adding all this to my Model model object, and I can
actually also specify it in my RDFWriter (see below). But the problem is
that one of these classes would always be referenced before it has been
declared, and therefore it gets an rdf:about identifier in a child element
below whatever references it, rather than an rdf:id in a completely "flat"
XML RDF structure (i.e. without any hierarchies in the serialized file). I
find this result weird (an "about" tag doesn't sound like an ID to me) but
recognize that it is probably okay according to the rdf spec. However, the
receiving end of this file requires a completely flat structure and
everything declared using rdf:id attributes. So I am reaching out to ask
if there is a way to tweak Jena's serializer to do this? Surely, there
must be a way to reference something which is declared further down the
file? Since the entire model is already established, I would find it an
odd limitation that such ordering in which elements are serialized should
be a limitation?
RDFWriter writer = model.getWriter("RDF/XML-ABBREV");
writer.setProperty("showXMLDeclaration", true);
writer.setProperty("xmlbase", NS);
writer.setProperty("prettyTypes", new Resource[] {
Ontology.ShuntCompensator,
Ontology.RegulatingControl,
Ontology.Terminal,
...
}
FileOutputStream fos;
fos = new FileOutputStream(filepath);
writer.write(model, fos, null);
Thanks a lot in advance!!
Nis
Nis Jespersen
Advisory IT Architect ? Energy & Utilities Global Center of Competency ?
IBM Global Business Services
+45 41208641 ? [email protected] ? IBM Danmark ApS, Lyngbyvej 2, 2100
Copenhagen, Denmark
-------- ------------- ------- -------
-------- ---------------- -------- --------
---- ---- ----- ------- -------
---- ------------ -------- --------
---- ------------ ---- ------- ----
---- ---- ----- ---- ----- ----
-------- ---------------- ------ --- ------
-------- ------------- ------ - ------
Medmindre andet er angivet ovenfor: / Unless Otherwise Stated Above:
IBM Danmark ApS
Nymøllevej 91
2800 Kongens Lyngby, Danmark
CVR nr.: 65305216