You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Paolo Castagna <ca...@googlemail.com> on 2011/11/17 10:24:12 UTC
Re: [jena-dev] is pure numbers permitted as individual names?
(for the archives)
@micky, the official Jena mailing list has moved to Apache. See here:
http://incubator.apache.org/jena/help_and_support/
Paolo
Dave Reynolds wrote:
> On Thu, 2011-11-17 at 03:10 +0000, micky wrote:
>>
>> Hi all, I am wandering is pure numbers (e.g. 123) permitted as
>> individual names?
>
> Judging by your code example I think you mean that you want a hash URI
> where the hash part is a digit string.
>
> Short answer: yes, that's legal though may trip you up
>
> Longer answer:
>
> A digit string is a legal fragment identifier in a URI and thus an IRI.
> The RDF model itself places no additional syntactic restrictions which
> stop you using it. However, not all legal RDF models can be serialized
> in all RDF syntaxes.
>
> In Turtle [1] then you are allowed pure digit strings as the LOCAL part
> of a prefixed name (which is defined by reference to SPARQL [2]). Even
> if that weren't the case you could always spell out the full "<...>" URI
> each time. So you can serialize it in Turtle (and indeed N-Triples) just
> fine.
>
> In RDF/XML you couldn't use such a URI for a class or property name
> because it is not possible to construct a legal QName which when
> concatenated would reconstruct that URI. You can use it for an
> individual name because then the URI need only be given via rdf:about or
> rdf:resource attributes. However, 123 isn't a legal XML ID and so you
> can't use rdf:ID - that isn't a problem so long as you are aware of it.
>
> The Jena getNamespace function is purely there to support generation of
> QName pairs that can be used in XML serializations. Which is why you get
> the (correct) results you do from the code sample. If you want to use
> identifiers of this shape and want to split your URIs in a "natural" way
> then write your own namespace function to just split at the last '#' or
> '/'.
>
> Dave
>
>
> [1] http://www.w3.org/2010/01/Turtle/
> [2] http://www.w3.org/TR/rdf-sparql-query/#rPN_LOCAL
>
>
>> Since Jena is not acting consistently on this issue (see code below).
>> Sorry if this question is too lame, but I am not able to find a
>> definite answer from W3C OWL specifications or by searching the web.
>> Thanks!
>> -----code-----
>> public class JenaApi {
>> public static void main(String args[]) {
>> String SOURCE = "http://www.eswc2006.org/technologies/ontology";
>> String NS = SOURCE + "#";
>> OntModel base =
>> ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM );
>> base.read( SOURCE, "RDF/XML" );
>> OntClass paper = base.getOntClass( NS + "Paper" );
>> Individual p1 = base.createIndividual( NS + "111", paper );
>> System.out.println("name space: "+p1.getNameSpace());
>> System.out.println("local name: "+p1.getLocalName());
>> Individual p2 = base.createIndividual( NS + "paper1", paper );
>> System.out.println("name space: "+p2.getNameSpace());
>> System.out.println("local name: "+p2.getLocalName());
>> }
>> }
>> -----output-----
>> name space: http://www.eswc2006.org/technologies/ontology#111
>> local name:
>> name space: http://www.eswc2006.org/technologies/ontology#
>> local name: paper1
>> -----end-----
>
>
>
>
>
>
> ------------------------------------
>
> The Jena user list is moving to Apache.
>
> The new list name is 'jena-users' and the mail server is 'incubator.apache.org'.
>
> Send email to
> 'jena-users-subscribe' at 'incubator.apache.org'
> to subscribe.
>
> Yahoo! Groups Links
>
> <*> To visit your group on the web, go to:
> http://groups.yahoo.com/group/jena-dev/
>
> <*> Your email settings:
> Individual Email | Traditional
>
> <*> To change settings online go to:
> http://groups.yahoo.com/group/jena-dev/join
> (Yahoo! ID required)
>
> <*> To change settings via email:
> jena-dev-digest@yahoogroups.com
> jena-dev-fullfeatured@yahoogroups.com
>
> <*> To unsubscribe from this group, send an email to:
> jena-dev-unsubscribe@yahoogroups.com
>
> <*> Your use of Yahoo! Groups is subject to:
> http://docs.yahoo.com/info/terms/
>