You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Dave Reynolds (JIRA)" <ji...@apache.org> on 2012/09/23 12:35:09 UTC
[jira] [Comment Edited] (JENA-331) XSDDatatype does not properly
handle URIs
[ https://issues.apache.org/jira/browse/JENA-331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13461365#comment-13461365 ]
Dave Reynolds edited comment on JENA-331 at 9/23/12 9:34 PM:
-------------------------------------------------------------
Thanks for the suggestion.
We originally left the java value for xsd:anyURI as a string because Jena has historically used Strings to carry URIs (which may or may not have been a good idea). We then allowed conversion from java.net.URI as a convenience extra.
I can see that sets up an expectation of round tripping but that's not possible in general, java.net.URI is not an adequate direct representation for anyURI. The lexical form for anyURI [1] allows strings not allowed by java.net.URI so that valid xsd:anyURI values (e.g. http://example.com/foo|bar) will throw URISyntaxExceptions. We could do the %-encoding in convertValidatedDataValue to convert the incoming anyURI syntax to a URI but I would rather not mess with lexical forms that way, too easy to end up with the wrong number of %-encodings applied.
An alternative would be to remove the support for URI or to replace it with IRI.
[1] http://www.w3.org/TR/xmlschema-2/#anyURI
was (Author: der):
Thanks for the suggestion.
We originally left the java value for xsd:anyURI as a string because Jena has historically used Strings to carry URIs (which may or may not have been a good idea). We then allowed conversion from java.net.URI as a convenience extra.
I can see that sets up an expectation of round tripping but that's not possible in general, java.net.URI is not an adequate direct representation for anyURI. The lexical form for anyURI [1] allows strings not allowed by java.net.URI so that valid xsd:anyURI values (e.g. http://example.com/foo|bar) will throw URISyntaxExceptions. We could do the %-encoding in convertValidatedDataValue to convert the incoming anyURI syntax to a URI I would rather not mess with lexical forms that way, too easy to end up with the wrong number of %-encodings applied.
An alternative would be to remove the support for URI or to replace it with IRI.
[1] http://www.w3.org/TR/xmlschema-2/#anyURI
> 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