On Wed, Mar 27, 2013 at 4:32 PM, Pastrana, Rodrigo (RIS-BCT)
<[email protected]> wrote:
>> You claim it's illegal.  Why?
> Did I? I pointed out the scenario, and asked if Jena's API can help handle it.
> Are you claiming the "congress people" RDF/XML graph is illegal?

I'd guess Andy meant where you wrote "Because the
com.hp.hpl.jena.rdf.model.Resource.getNameSpace() will potentially
return invalid namespaces (if the name starts with a numeral or
contains a dot)."  That's not all that relevant though.  There's not
illegal about the congress people RDF/XML graph.  RDF is defined in
terms of IRIs, and RDF can be serialized in a number of formats.  Some
of those formats provide convenient ways to write IRIs in shortened
form, but also rule out writing certain of the IRIs in shortened form.
 Some of the IRIs in the congress people graph can't be written in the
shortened form.  It doesn't make the graph illegal in any sense, and
it doesn't even mean that the graph can't be serialized in RDF/XML;
it only means that not every IRI in the graph can be written in the
XML qname format.

> Doesn't really matter, what matters is this scenario will play out in many 
> RDF/XML graphs.
> We want to use JENA, but we have to be able to support RDF/XML graphs such as 
> the congress people...

Jena supports RDF/XML, and you'll be able to use Jena to work with
that graph.  You won't be able to access everything though XML qnames,
though.  That's not uncommon, and it's not really a problem.  Here's
example of Jena code that works with a graph containing the triple you
mentioned above.  It shows the behavior you've described (i.e.,
getLocalName returning "") as well as some serializations of the
model.  The fact that certain IRIs can't be represented in the XML
Qname syntax doesn't keep them from being used in RDF graphs, or even
from being serialized in RDF/XML.

import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
import com.hp.hpl.jena.vocabulary.RDF;

public class Congress {
        public static void main(String[] args) {
                Model model = ModelFactory.createDefaultModel();
                Resource wilson = model.createResource(
"http://www.rdfabout.com/rdf/usgov/congress/people/412360"; );
                Resource foafPerson = model.createResource(
"http://xmlns.com/foaf/0.1/Person"; );
                model.add( wilson, RDF.type, foafPerson );
                
                for ( Resource r : new Resource[] { wilson, foafPerson } ) {
                        System.out.println( "namespace: '" + r.getNameSpace() + 
"';
localname: '"+r.getLocalName()+"'" );;
                }
                
                for ( String format : new String[] { "RDF/XML", 
"RDF/XML-ABBREV", "TTL" } ) {
                        System.out.println( "\n== "+format+" ==" );
                        model.write( System.out, format );
                }
        }
}

Output:

namespace: 'http://www.rdfabout.com/rdf/usgov/congress/people/412360';
localname: ''
namespace: 'http://xmlns.com/foaf/0.1/'; localname: 'Person'

== RDF/XML ==
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
    xmlns:j.0="http://xmlns.com/foaf/0.1/"; >
  <rdf:Description
rdf:about="http://www.rdfabout.com/rdf/usgov/congress/people/412360";>
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person"/>
  </rdf:Description>
</rdf:RDF>

== RDF/XML-ABBREV ==
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
    xmlns:j.0="http://xmlns.com/foaf/0.1/";>
  <j.0:Person 
rdf:about="http://www.rdfabout.com/rdf/usgov/congress/people/412360"/>
</rdf:RDF>

== TTL ==
<http://www.rdfabout.com/rdf/usgov/congress/people/412360>
      a       <http://xmlns.com/foaf/0.1/Person> .


-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to