You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Claude Warren (JIRA)" <ji...@apache.org> on 2012/09/22 09:41:07 UTC

[jira] [Updated] (JENA-331) XSDDatatype does not properly handle URIs

     [ https://issues.apache.org/jira/browse/JENA-331?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Claude Warren updated JENA-331:
-------------------------------

    Attachment: JENA-331.patch

Patch to add URI creation on parse
                
> XSDDatatype does not properly handle URIs
> -----------------------------------------
>
>                 Key: JENA-331
>                 URL: https://issues.apache.org/jira/browse/JENA-331
>             Project: Apache Jena
>          Issue Type: Improvement
>          Components: Jena
>    Affects Versions: Jena 2.7.3
>            Reporter: Claude Warren
>         Attachments: JENA-331.patch
>
>
> Using the TypeMapper to convert a URI to a literal and back again fails as a String is returned not a URI.
> Test code:
> import com.hp.hpl.jena.datatypes.RDFDatatype;
> import com.hp.hpl.jena.datatypes.TypeMapper;
> import com.hp.hpl.jena.rdf.model.Literal;
> import com.hp.hpl.jena.rdf.model.ResourceFactory;
> import java.net.URI;
> import org.junit.Assert;
> import org.junit.Test;
> public class XSDDatatypeTest
> {
>  @Test
>  public void testURIConversion() throws Exception
>  {
> 	 TypeMapper typeMapper = TypeMapper.getInstance();
> 	 RDFDatatype dt = typeMapper.getTypeByClass( java.net.URI.class );
> 	 URI uri = new URI("http://example.com" );
> 	 String lexicalForm = dt.unparse( uri );
> 	 Literal l = ResourceFactory.createTypedLiteral( lexicalForm, dt );
> 	
> 	 Object o = dt.parse( l.getLexicalForm()  );
> 	 Assert.assertEquals( uri, o );
>  }
> }

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira