Hi Steve,
I can't seem to get your example to give me <tn:TaxonName rdf:about="lsid info">, it just seems to add a property.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#%22%3E <rdf:Description rdf:about="urn:lsid:zoobank.org:taxon:123"> rdf:typehttp://tdwg.org/2006/03/12/TaxonNames/TaxonName</rdf:type> </rdf:Description> </rdf:RDF>
From my code...
ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Model model = ModelFactory.createDefaultModel(); Resource res = model.createResource(lsid.toString()); res.addProperty(model.createProperty("http://www.w3.org/1999/02/22-rdf-s yntax-ns#type"), TN_NS + "TaxonName");
model.write(byteStream, "RDF/XML-ABBREV"); return new MetadataResponse(new ByteArrayInputStream(byteStream.toByteArray()),null,MetadataResponse.RDF _FORMAT);
Many thanks, Peter.
-----Original Message----- From: Steve Perry [mailto:smperry@ku.edu] Sent: 25 September 2006 20:54 To: Hollas, Peter (TS UK); tdwg-guid@mailman.nhm.ku.edu Subject: Re: [Tdwg-guid] Jena examples?
Hi Peter,
Ben is right. To get a TaxonName element (instead of an rdf:Description), add the following line of code:
res.addProperty(model.createProperty(" http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), TN_NS + "TaxonName");
This should give you output like :
<rdf:RDF xmlns:j.0="http://tdwg.org/2006/03/12/TaxonNames" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#%22%3E <j.0:TaxonName rdf:about="http://test%22%3E j.0:testPropertytest</j.0:testProperty> </j.0:TaxonName> </rdf:RDF>
XML namespace prefixes are not preserved in RDF so Jena will supply its own prefixes when serializing to one of the XML formats (hence the j.0 instead of tn).
By the way, the IPNI example you cite has an error:
<tn:nomenclaturalCode rdf:resource="&tn;#botanical" />
Many RDF/XML parsers will see &tn; as an entity which cannot be resolved. Since I don't have a copy of the ontology (and http://tdwg.org/2006/03/12/TaxonNames does not resolve), I can only take
a guess that it should look something like:
<tn:nomenclaturalCode rdf:resource="tn:botanical" />
However, using XML namespace prefixes in resource references inside RDF/XML documents tends to cause problems because not all RDF/XML parsers are smart enough to dereference the namespace prefix and build a
fully-qualified resource URI. A safer form of the above would be the fully qualified resource URI which looks like:
<tn:nomenclaturalCode rdf:resource="http://tdwg.org/2006/03/12/TaxonNames/botanical" />
-Steve
Benjamin H Szekely wrote:
Hi Peter, In XML/ABBREV mode, the serializer uses rdf:Types for element
names.
Since your example doesn't have an rdf:Type, it uses the default Jena element names.
- Ben
Ben Szekely IBM Software Engineer Advanced Internet Technology, Cambridge, MA bhszekel@us.ibm.com
tdwg-guid-bounces@mailman.nhm.ku.edu wrote on 09/25/2006 11:02:30 AM:
Hi Everyone,
Does anyone have/or know of any good examples of using Jena to output RDF metadata with non-typical namespaces such as TCS/RDF?
Currently I have the following code for my metadata method(I know
it's
wrong!).
String TN_NS = "http://tdwg.org/2006/03/12/TaxonNames/"; ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); Model model = ModelFactory.createDefaultModel(); Resource res = model.createResource("http://test"); res.addProperty(model.createProperty(TN_NS,"testProperty"),"test");
model.write(byteStream, "RDF/XML-ABBREV"); return new MetadataResponse(new
ByteArrayInputStream(byteStream.toByteArray()),null,MetadataResponse.RDF
_FORMAT);
...which gives me.
<rdf:RDF xmlns:j.0="http://tdwg.org/2006/03/12/TaxonNames/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#%22%3E <rdf:Description rdf:about="http://test%22%3E <j.0:testProperty >test</j.0:testProperty> </rdf:Description> </rdf:RDF>
...whereas I could really do with something along the lines of the
IPNI
metadata.
<rdf:RDF xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:tn="http://tdwg.org/2006/03/12/TaxonNames/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#%22%3E
<!-- example family (has an unlinked typifying name with
non-
standard format data)--> tn:TaxonName rdf:about="urn:lsid:ipni.org:names:30000959-2:1.1.2.1" <tn:nomenclaturalCode rdf:resource="&tn;#botanical" /> dc:titleAmaryllidaceae J.St.-Hil.</dc:title> dcterms:created2004-01-20 00:00:00.0</dcterms:created> dcterms:modified2005-06-23 15:45:33.0</dcterms:modified> tn:rankStringfam.</tn:rankString> tn:nameCompleteAmaryllidaceae</tn:nameComplete> tn:uninomialAmaryllidaceae</tn:uninomial> tn:authorshipJ.St.-Hil.</tn:authorship> tn:publishedInExpos. Fam. Nat. 1: 134. 1805 [Feb-Apr 1805]</tn:publishedIn> tn:year1805</tn:year> tn:typifiedBy tn:NomenclaturalType dc:titleAmaryllis Linnaeus, nom. cons.</dc:title> </tn:NomenclaturalType> </tn:typifiedBy> </tn:TaxonName>
I think the main problem I have is creating resources that aren't defined as vocabularies within Jena already. I can't seem to find a
way
to create that <tn:TaxonName root resource element.
I'm starting to think that just outputting vanilla text could be the best option here, or am I barking up the wrong tree?
Many thanks, Peter.
Peter Hollas MSc BSc(hons) (Peter.Hollas@thomson.com) Software Engineer /Systems Administrator Thomson Zoological Innovation Centre York Science Park Heslington York YO10 5DG
Tel: 01904-435113 Fax: 01904-435114
TDWG-GUID mailing list TDWG-GUID@mailman.nhm.ku.edu http://mailman.nhm.ku.edu/mailman/listinfo/tdwg-guid
------------------------------------------------------------------------
TDWG-GUID mailing list TDWG-GUID@mailman.nhm.ku.edu http://mailman.nhm.ku.edu/mailman/listinfo/tdwg-guid