|
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:
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. |
|
No you can't: According to the Relax NG the rdf:about statement requires an URI reference:
A RDF URI reference is defined as follows:
|
|
It seems like it does not work in practice, either. Given the xml input <?xml version="1.0"?> 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" . |
|
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. |
|
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: |


Thanks for all the helpful answers!