Re: Literal string to appropriate object

2017-01-12 Thread Claude Warren
You might look at how PA4RDF handled the problem. https://github.com/Claudenw/PA4RDF in https://github.com/Claudenw/PA4RDF/blob/master/src/main/java/org/xenei/jena/entities/impl/PredicateInfoImpl.java the method getHandler() has code that determines what the return type is for a literal. The

Re: Literal string to appropriate object

2017-01-12 Thread George News
On 12/01/2017 11:31, Dave Reynolds wrote: > > On 12/01/17 10:15, George News wrote: >> BTW I think I found a bug: >> >> String b = "http://datypic.com/fraf1;; >> Literal a = (Literal) ResourceFactory.createTypedLiteral(b, >> XSDDatatype.XSDanyURI); >> System.out.println(a.getDatatype()); >>

Re: Literal string to appropriate object

2017-01-12 Thread George News
On 12/01/2017 11:33, Rob Vesse wrote: > Why are you using literals to represent URIs? > > Most people would just use URIs since they are first-class citizens in the > RDF datamodel. It seems like you are forcing yourself through unnecessary > hoops It's representing an endpoint to access a

Re: Literal string to appropriate object

2017-01-12 Thread Rob Vesse
Why are you using literals to represent URIs? Most people would just use URIs since they are first-class citizens in the RDF datamodel. It seems like you are forcing yourself through unnecessary hoops Rob On 12/01/2017 10:15, "George News" wrote: BTW I think I found

Re: Literal string to appropriate object

2017-01-12 Thread Dave Reynolds
On 12/01/17 10:15, George News wrote: BTW I think I found a bug: String b = "http://datypic.com/fraf1;; Literal a = (Literal) ResourceFactory.createTypedLiteral(b, XSDDatatype.XSDanyURI); System.out.println(a.getDatatype()); System.out.println(a.getValue().getClass()); a = (Literal)

Re: Literal string to appropriate object

2017-01-12 Thread George News
BTW I think I found a bug: String b = "http://datypic.com/fraf1;; Literal a = (Literal) ResourceFactory.createTypedLiteral(b, XSDDatatype.XSDanyURI); System.out.println(a.getDatatype()); System.out.println(a.getValue().getClass()); a = (Literal)

Re: Literal string to appropriate object

2017-01-12 Thread George News
On 12/01/2017 9:58, Chris Dollin wrote: > > > On 12/01/17 08:41, George News wrote: >> >> >> On 11/01/2017 18:17, A. Soroka wrote: >>> And I and Chris Dollin answered your question. Again, >>> >>> ResourceFactory.createTypedLiteral("http://hola^^http://www.w3.org/2001/XMSchema#anyURI;, >>>

Re: Literal string to appropriate object

2017-01-12 Thread Lorenz B.
Exactly, first argument is the value, second one declares the datatype - here XSDDatatype.XSDanyURI, see the Javadoc [1] [1] https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/ResourceFactory.html#createTypedLiteral-java.lang.String-org.apache.jena.datatypes.RDFDatatype-

Re: Literal string to appropriate object

2017-01-12 Thread Dave Reynolds
On 12/01/17 08:41, George News wrote: On 11/01/2017 18:17, A. Soroka wrote: And I and Chris Dollin answered your question. Again, ResourceFactory.createTypedLiteral("http://hola^^http://www.w3.org/2001/XMSchema#anyURI;, XSDDatatype.XSDanyURI) That should be:

Re: Literal string to appropriate object

2017-01-12 Thread Chris Dollin
On 12/01/17 08:41, George News wrote: On 11/01/2017 18:17, A. Soroka wrote: And I and Chris Dollin answered your question. Again, ResourceFactory.createTypedLiteral("http://hola^^http://www.w3.org/2001/XMSchema#anyURI;, XSDDatatype.XSDanyURI) Don't do a bunch of string processing. As I

Re: Literal string to appropriate object

2017-01-12 Thread George News
On 11/01/2017 18:17, A. Soroka wrote: > And I and Chris Dollin answered your question. Again, > > ResourceFactory.createTypedLiteral("http://hola^^http://www.w3.org/2001/XMSchema#anyURI;, > XSDDatatype.XSDanyURI) > > Don't do a bunch of string processing. As I said there is no way of getting

Re: Literal string to appropriate object

2017-01-11 Thread A. Soroka
You do know the type: http://www.w3.org/2001/XMSchema#anyURI It is clearly written in your example. --- A. Soroka The University of Virginia Library > On Jan 11, 2017, at 10:25 AM, George News wrote: > > On 11/01/2017 15:59, A. Soroka wrote: >> Perhaps parse it as a Jena

Re: Literal string to appropriate object

2017-01-11 Thread Chris Dollin
On 11/01/17 15:42, George News wrote: Literal a = (Literal) ResourceFactory.createTypedLiteral("http://hola^^http://www.w3.org/2001/XMSchema#anyURI;, XSDDatatype.XSDanyURI); System.out.println(a.getDatatype()); System.out.println(a.getLexicalForm()); System.out.println(a.getDatatypeURI());

Re: Literal string to appropriate object

2017-01-11 Thread George News
At the end I decide to take a shortcut that also might help explain what I want: |private URI rdfLiteralToUri(String literal) { int xsdIndex = literal.lastIndexOf("^^"); if (xsdIndex == -1) { throw new IllegalArgumentException("Not valid literal format"); } String uriStr = literal.substring(0,

Re: Literal string to appropriate object

2017-01-11 Thread George News
On 11/01/2017 16:25, Chris Dollin wrote: > > > On 11/01/17 14:55, George News wrote: >> Hi, >> >> I have this literal: >> http://hola^^http://www.w3.org/2001/XMSchema#anyURI > > What do you mean by "have"? A String value, a Literal > value, or what? I want to get http://hola as a String or as

Re: Literal string to appropriate object

2017-01-11 Thread Chris Dollin
On 11/01/17 14:55, George News wrote: Hi, I have this literal: http://hola^^http://www.w3.org/2001/XMSchema#anyURI What do you mean by "have"? A String value, a Literal value, or what? And I want to create a URI from it. Is there any way to do so? And do you want an actual URI object or

Re: Literal string to appropriate object

2017-01-11 Thread George News
On 11/01/2017 15:59, A. Soroka wrote: > Perhaps parse it as a Jena Literal (e.g. using > ResourceFactory.createTypedLiteral() ), then use Literal.getString() to get > the value you seek. then I need to know the type. The issue is that I wanted to know if there is any Jena function that directly

Re: Literal string to appropriate object

2017-01-11 Thread A. Soroka
Perhaps parse it as a Jena Literal (e.g. using ResourceFactory.createTypedLiteral() ), then use Literal.getString() to get the value you seek. --- A. Soroka The University of Virginia Library > On Jan 11, 2017, at 9:55 AM, George News wrote: > > Hi, > > I have this