Creating a $.rdf.literal with user-defined datatype

19 views
Skip to first unread message

Norman Heino

unread,
Mar 8, 2010, 8:17:25 AM3/8/10
to rdfq...@googlegroups.com
Hello, 

I am using rdfQuery in a project where I need to create literals with user-defined datatypes, e.g. "123"^^<http://ns.aksw.org/types/myIntegerSubset>

I tried creating such a literal using the following code:

   var l = $.rdf.literal('"123"^^akswt:myIntegerSubset', {namespaces: {'akswt': 'http://ns.aksw.org/types/'}});

However, rdfQuery throws the following exception:

   InvalidDatatype: The datatype http://ns.aksw.org/types/myIntegerSubset can't be recognised

Am I missing something here or are user-defined datatypes not supported?

Regards, 
Norman

bblfish

unread,
Mar 8, 2010, 12:35:37 PM3/8/10
to rdfQuery
As a matter of interest we have some code using Sesame ( http://openrdf.org/
)
that queries my home page http://bblfish.net/ for our user defined
datatypes.

http://bit.ly/9XQZ8O

It works. It would be nice of course if we could add to sesame some
code to do inferencing on this datatype.

Just a helpful pointer...

On Mar 8, 2:17 pm, Norman Heino <norman.he...@googlemail.com> wrote:
> Hello,
>
> I am using rdfQuery in a project where I need to create literals with user-defined datatypes, e.g. "123"^^<http://ns.aksw.org/types/myIntegerSubset>
>
> I tried creating such a literal using the following code:
>
>    var l = $.rdf.literal('"123"^^akswt:myIntegerSubset', {namespaces: {'akswt': 'http://ns.aksw.org/types/'}});
>
> However, rdfQuery throws the following exception:
>

>    InvalidDatatype: The datatypehttp://ns.aksw.org/types/myIntegerSubsetcan't be recognised

Jeni Tennison

unread,
Mar 8, 2010, 5:05:17 PM3/8/10
to rdfq...@googlegroups.com
Norman,

You can use user-defined datatypes, but you should define it as a type
like this:

$.typedValue.types['http://ns.aksw.org/types/myIntegerSubset'] = {
regex: /^[\-\+]?[0-9]+$/,
strip: true,
value: function (v) {
return parseInt(v, 10);
}
};

You can define a validate property for the type as well, if you want,
for example to test that all the values are between certain numbers.

Jeni

> --
> You received this message because you are subscribed to the Google
> Groups "rdfQuery" group.
> To post to this group, send email to rdfq...@googlegroups.com.
> To unsubscribe from this group, send email to rdfquery+u...@googlegroups.com
> .
> For more options, visit this group at http://groups.google.com/group/rdfquery?hl=en
> .

--
Jeni Tennison
http://www.jenitennison.com

Norman Heino

unread,
Mar 9, 2010, 12:17:04 PM3/9/10
to rdfq...@googlegroups.com
Thank you Jeni, that did the trick.

Norman

Reply all
Reply to author
Forward
0 new messages