Am I supposed to be able to use a namespace prefix when referring to a subject with the "rdf:about" attribute in RDF/XML, like so:

<rdf:RDF xmlns:myns="http://example.org/someBaseURI#">
<rdf:Description rdf:about="myns:someEntity">
... 

I can't find any such example on the net, and the RDF library I'm using (ARC2) doesn't seem to support it, so I wanted to make clear whether it is supposed to work or not according to standards.

asked 10 Jul '10, 21:55

Samuel%20Lampa's gravatar image

Samuel Lampa
698311
accept rate: 33%

Thanks for all the helpful answers!

(12 Jul '10, 13:10) Samuel Lampa Samuel%20Lampa's gravatar image

No you can't: According to the Relax NG the rdf:about statement requires an URI reference:

aboutAttr = 
  attribute rdf:about { 
    URI-reference 
}

A RDF URI reference is defined as follows:

6.4 RDF URI References

A URI reference within an RDF graph (an RDF URI reference) is a Unicode string that:

• does not contain any control characters ( #x00 - #x1F, #x7F-#x9F)
• and would produce a valid URI character sequence (per RFC2396 [URI], sections 2.1) representing an absolute URI with optional fragment identifier when subjected to the encoding described below.

http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/#dfn-URI-reference

permanent link

answered 10 Jul '10, 22:12

Markus%20Lanthaler's gravatar image

Markus Lanth...
19416
accept rate: 50%

No you can't. This is one of the many reasons why Turtle is so much better than RDF/XML.

permanent link

answered 11 Jul '10, 00:59

cygri's gravatar image

cygri ♦
9.0k412
accept rate: 34%

It seems like it does not work in practice, either. Given the xml input

  <?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:myns="http://example.org/someBaseURI#">
<rdf:Description rdf:about="myns:someEntity">
<myns:someProperty>foo</myns:someProperty>
</rdf:Description>
</rdf:RDF>

The W3C's validator doesn't complain, but produces a triple with the subject prefix not expanded.

  myns:someEntity http://example.org/someBaseURI#someProperty "foo" .

Running it through cwm produces similar results.

  ~> cwm --rdf test.xml --ntriples
  <myns:someEntity> <http://example.org/someBaseURI#someProperty> "foo" .
permanent link

answered 11 Jul '10, 00:53

Tim%20Finin's gravatar image

Tim Finin
701128
accept rate: 25%

As others have said, no you can't. You can, however, define the prefix as an XML entity at the head of the file, so that you only have one place to keep prefixes up-to-date. The principle problem with this approach (other than the ugly XML entity syntax) is that few, if any, RDF tools that I can think of will preserve XML entity declarations between reading and subsequent writing. So it works OK on files that you directly edit yourself in a text editor or XML editor, but not otherwise.

Having said that, I'd agree with Richard that using Turtle as your input syntax is a better idea. If you need XML as part of your toolchain, there are tools that can convert Turtle to XML.

permanent link

answered 11 Jul '10, 14:36

Ian's gravatar image

Ian
42716
accept rate: 0%

No. You can't use a namespace prefix in an rdf:about attribute.

The specification explains that the rdf:about attribute is a URI Reference:

http://www.w3.org/TR/REC-rdf-syntax/#aboutAttr

From an XML perspective there are a number of issues with allowing the use of QNames in Content. See this tag finding for discussion:

http://www.w3.org/2001/tag/doc/qnameids

Other RDF serializations do allow prefixed names as e.g. CURIE's:

http://en.wikipedia.org/wiki/CURIE

permanent link

answered 12 Jul '10, 11:24

ldodds's gravatar image

ldodds
1.8k1314
accept rate: 32%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×39
×34

question asked: 10 Jul '10, 21:55

question was seen: 4,521 times

last updated: 12 Jul '10, 11:24