Saturday, October 23, 2010

Adding ENTITIES to the generated RDF

If you have to embed typed resources as literals within an RDF, such in this example:

• <dcterms:identifier rdf:resource="&xxx;type#TheDataValue"/>

The xxx entity abbreviation must be declared outside the RDF core, in the XML DOCTYPE main node. Something like:

<!ENTITY xsd "">
<!ENTITY xxx "">

So, the question is: how to implement this in Jena, considering Jena RDF write just outputs the RDF tree...?
As shown in this Jena file i/o how-to, Jena provides some advanced output configuration options that can control the generation of those items.
Indeed, there are two options that can be useful in generating the extra ENTITY references.

Those are:
  • showXmlDeclaration:
"If true, an XML Declaration is included in the output, if false no XML declaration is included. The default behaviour only gives an XML Declaration when asked to write to an OutputStreamWriter that uses some encoding other than UTF-8 or UTF-16. In this case the encoding is shown in the XML declaration. To ensure that the encoding attribute is shown in the XML declaration either:
Set this option to true and use the write(Model,Writer,String) variant with an appropriate OutputStreamWriter.
Or set this option to false, and write the declaration to an OutputStream before calling write(Model,OutputStream,String)."
  • showDoctypeDeclaration:
"If true, an XML Doctype declaration is included in the output. This declaration includes a !ENTITY declaration for each prefix mapping in the model, and any attribute value that starts with the URI of that mapping is written as starting with the corresponding entity invocation."

Tuesday, October 19, 2010

How-to get rid of auto-generated prefixes in Jena.

During my first experiments with Jena to read and produce custom ontologies, I suddenly faced the auto-generated namespace glitch that jena produces when rendering ontologies as RDF (XML view). After a bit o search around the subject, I got to the solution (by narrowing my search after a while).

According to this post, whose blog now I follow, one solution would be to use N3. Now if you can´t get away with and must render it to RDF, the fix is pretty simple.

The key to this is the PrefixMapping interface, which is a super-interface of Model. The method setNsPrefix lets us assign a more meaningful (to human readers!) namespace:

public static void main( String[] args ) {
Model m = ModelFactory.createDefaultModel();
String NS = "";
m.setNsPrefix( "eg", NS );
Property p = m.createProperty( NS + "p" );
Resource r = m.createResource( NS + "r" );
r.addProperty( p, 42 );
m.write( System.out, "RDF/XML" );


xmlns:rdf="" >
<rdf:description about="">

As I said, pretty simple.

Wednesday, June 23, 2010

Getting semantic data out of the web

After populating my online profiles with enough semantic data to be able to query, I wanted to test some of the semantic search engines (and indexers) to see what comes out when searching for my own name.

Some of the social networks available in the internet have already exposed semantic data about its users, so this means you can get some results out of the search engines without having submitted or published and semantic (structured) information yourself.

Of the semantic search engines available I chose the two that returned the largest number of triples related to my name:

You can see the results yourself by clicking on each of the following links

Observe the most number of triples (around 300) returned for my RFID, xhtml/rdfa identity page.
Also see like SIG.MA breaks the explicit and implicit (inferred) terms identified.
Try it with your own name, or with the name of some public celebrity...

Friday, March 12, 2010

FOAF file linking and browsing data.

After the initial load of my FOAF file, I´ve added extra links to other FOAF formatted data provided by the online social sites I participate.
For instance, sites like livejournal, and some others,provide a link to your profile data RDF ready formatted for FOAF.

On those sites, the RDF endpoints (FOAF) for my profiles there, can be referenced (and related to an object - Person tag within they are defined) inside the personal FOAF file ( using OWL (The Web Ontology Language):

<owl:sameAs rdf:resource=""/>
<owl:sameAs rdf:resource=""/>

Unlikelym Facebook for instance, does not expose it´s data as foaf. But thanks to Matthew Rowe who developed Facebook FOAF Generator, you can extract its data and save it into a foaf file.

The great part here is that we are using FOAF to excercise the OWL relationships because there is a large amount of data already online. But this can relate any kind of information of any types.

Now using an RDF browser such as the one at, and entering one of the FOAF addresses ( to explore, navigate and aggregate all the data the LINKED data.

The next step is to make all those data inter-relationships to work as expected, which btw for is the key part to the success of RDF data modelling. For instance usage of rdf: resource where it should be rdf:about, and so on...

Tuesday, March 9, 2010

Personal FOAF page up and running!

That´s it... After reading and going through different sources, I managed to get my personal FOAF identity page based on RDFa+XHTML.
Ok, the html is pretty rough and needs some improvement in the formatting.
Now I plan to put some microformats on it, and some more fellows because I have just put one of my fiends just to prove the concept.
I also expect to link it back to other FOAF profiles of mine.
If you check the airport section in the xhtml file, you´ll notice I implemented the XHTML part based on the RDF one.

Sure there is lots of room for improvement. But it´s a start and it passed w3c validation for RDFa+XHTML and the XHTML Markup validation too. Woohooo!

Special Thanks to Michael Hausenblas for all the insight!

Sunday, March 7, 2010

To start with...

Hi and welcome to my new blog dedicated to my research and experiences with semantic web, linked data and all the related technologies known to this moment or even to be conceived.

Although I could have posted this as a section of my software development blog (see the lastest posts from at the top of this page), I though the complexity of the matter deserved a dedicated channel.

The idea is to publish here all the findings, updates, other sorts of bits related, and to get feedback from / listen to the community interested in the subject.

And to exercise my findings I used all the otherwise unlinked mesh of social networks. In a way to establish a common identity source that relates actually, the same people in different places.

I´ll refer to the work of other researchers as there are some folks that have already bee working on this for quite a long time.

Michael is one of those researchers, whose blog pointed me on some directions where to look at.