Dragos
Dragos

Reputation: 2981

What is the role of the xmlns attributes in RDF?

I am new to RDF and I am trying to get some RDF files from the web. For example:

http://rdf.freebase.com/rdf/venture_capital.views.investment_round

or

http://sws.geonames.org/2950159/about.rdf

The problem is, that I should add a few xmlns attributes to the tag, but I don't know which nor why. Also, should I add a xml header or not?

Upvotes: 1

Views: 739

Answers (2)

Quentin
Quentin

Reputation: 943142

What is the role of the xmlns attributes in RDF?

They let you distinguish <foo> from namespace a from <foo> from namespace b (where it might be something subtly different … or completely different.

The problem is, that I should add a few xmlns attributes to the tag, but I don't know which nor why.

It is rather had to know "why" or "which" without knowing the other (or at least "on what"). Why do you think you need to add them if you don't know what or why?

Also, should I add a xml header or not?

Define "xml header". If you mean the XML declaration of <?xml ... ?> then you only need that if you aren't using the defaults (UTF-8/16 and XML 1.0)

Upvotes: 2

Nils Weinander
Nils Weinander

Reputation: 2131

In order to use tags you need to declare the RDF namespace

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

likewise for any of your own namespaces. All XML files should have an XML header.

E.g.

<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  xmlns:myns="http://my.domain/schema#"
>
   <myns:something rdf:about="http://my.domain/data/item.1">
      <rdf:type rdf:resource="http://my.domain/schema/thing"/>
      <myns:property1>Value</myns:property1>
   </myns:something>
</rdf:RDF>

Upvotes: 2

Related Questions