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 only "http://hola" which is the value. I don't know what I'm doing wrong but cannot get it. Example with all possible functions: String b = "http://hola^^http://www.w3.org/2001/XMLSchema#anyURI"; Literal a = (Literal) ResourceFactory.createTypedLiteral(b, XSDDatatype.XSDanyURI); System.out.println(a.getDatatype()); System.out.println(a.getLexicalForm()); System.out.println(a.getDatatypeURI()); System.out.println(a.getString()); System.out.println(a.getValue()); System.out.println(a.toString()); Output: Datatype[http://www.w3.org/2001/XMLSchema#anyURI -> class java.net.URI] http://datypic.com/fraf1^^http://www.w3.org/2001/XMLSchema#anyURI http://www.w3.org/2001/XMLSchema#anyURI http://datypic.com/fraf1^^http://www.w3.org/2001/XMLSchema#anyURI http://datypic.com/fraf1^^http://www.w3.org/2001/XMLSchema#anyURI http://datypic.com/fraf1^^http://www.w3.org/2001/XMLSchema#anyURI^^http://www.w3.org/2001/XMLSchema#anyURI If I run the same code using a integer: a = ResourceFactory.createTypedLiteral("\"5\"^^http://www.w3.org/2001/XMLSchema#int", XSDDatatype.XSDint); I get an exception: org.apache.jena.datatypes.DatatypeFormatException. I'm suggesting there should be a function like createTypedLiteral(String literal) where literal is a well-formatted literal. Then using the parsing from ^^ internally will be able to extract the type and somehow obtain the same outcome as the createTypedLiteral(String, Datatype) function. I guess that internally there should be such a function. Thanks a lot for your help and understanding. See you Jorge > > --- > A. Soroka > The University of Virginia Library > >> On Jan 11, 2017, at 12:11 PM, George News <george.n...@gmx.net> wrote: >> >> >> >> On 11/01/2017 17:18, A. Soroka wrote: >>> You do know the type: http://www.w3.org/2001/XMSchema#anyURI >>> >>> It is clearly written in your example. >> >> I know. What I wanted is to know if there is a utility in Jena that >> parses the string, like the example function I posted. >> >> Thanks for your help. >> >>> --- >>> A. Soroka >>> The University of Virginia Library >>> >>>> On Jan 11, 2017, at 10:25 AM, George News <george.n...@gmx.net> wrote: >>>> >>>> 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 parses the literal in the >>>> Turtle (or any other) form and get the object type. >>>> >>>>> --- >>>>> A. Soroka >>>>> The University of Virginia Library >>>>> >>>>>> On Jan 11, 2017, at 9:55 AM, George News <george.n...@gmx.net> wrote: >>>>>> >>>>>> Hi, >>>>>> >>>>>> I have this literal: >>>>>> http://hola^^http://www.w3.org/2001/XMSchema#anyURI >>>>>> >>>>>> And I want to create a URI from it. Is there any way to do so? >>>>>> >>>>>> I have tried >>>>>> URI z = (URI) XSDDatatype.XSDanyURI.parseValidated(literalString); >>>>>> >>>>>> but I get: >>>>>> java.lang.ClassCastException: java.lang.String cannot be cast to >>>>>> java.net.URI >>>>>> >>>>>> I don't know if I should take the shortcut, that is, remove everything >>>>>> after ^^ using substring, and then URI.create(shortenedLiteralString). >>>>>> >>>>>> Any help is welcome. >>>>>> Jorge >>>>> >>>>> >>> >>> > >