Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing to parse turtle file #515

Open
cristianvasquez opened this issue Nov 20, 2024 · 8 comments
Open

failing to parse turtle file #515

cristianvasquez opened this issue Nov 20, 2024 · 8 comments
Labels
Bug Something isn't working
Milestone

Comments

@cristianvasquez
Copy link

Hi,

Thank you for creating SPARQL Anything—it’s an incredible tool!

I’m encountering an issue while trying to fetch a Turtle file from the web. The file I’m working with contains the following content:

<a> <b> <c> .

I can successfully fetch and query this file locally using the following query:

PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT *
WHERE {
  {
    SERVICE <x-sparql-anything:> {
      fx:properties fx:media-type "text/turtle" ;
                    fx:location "http://127.0.0.1:8080/file.ttl" .
      ?s ?p ?o .
    }
  }
}

However, if I rename the file to have a different extension (e.g., file.something), it fails to parse. This leads me to suspect that the fx:media-type property is not being respected in this case.

Could you provide any guidance or confirm if this is a bug?

Thank you!

@luigi-asprino luigi-asprino added the Bug Something isn't working label Nov 20, 2024
@luigi-asprino luigi-asprino added this to the v1.0.0 milestone Nov 20, 2024
luigi-asprino added a commit that referenced this issue Nov 20, 2024
@luigi-asprino
Copy link
Member

Hi

Thank you for creating SPARQL Anything—it’s an incredible tool!

Glad to hear that :-)

This is a bug.

The media type is used to select the triplifier, but when it comes to reading the file and identifying the language, it is ignored and the triplifier cannot determine the language and therefore cannot read it.

5c42c1f should fix the problem

@kvistgaard
Copy link
Contributor

@luigi-asprino that's great. Can you please include that fix in the next pre-release?

@luigi-asprino
Copy link
Member

It is the https://github.com/SPARQL-Anything/sparql.anything/releases/tag/v1.0-DEV.9

@luigi-asprino
Copy link
Member

I think we can close this issue now

@cristianvasquez
Copy link
Author

cristianvasquez commented Jan 17, 2025

Hello @luigi-asprino, could we re-open the issue?

I'm getting the same error when using a remote file containing the following:

PREFIX fx: <http://sparql.xyz/facade-x/ns/>

<a> <b> <c> .
[main] ERROR org.apache.jena.riot - [line: 1, col: 1 ] Expected BNode or IRI: Got: [KEYWORD:PREFIX]

The query:

PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT *
WHERE {
  SERVICE <x-sparql-anything:> {
    fx:properties
      fx:location "https://gist.githubusercontent.com/cristianvasquez/45b1c05729b9bf469da67ac18cf32519/raw/c4f93f95bf43047bac213df414bad61e88631b15/mini.ttl" ;
      fx:media-type "text/turtle" .
?s ?p ?o .
  }
}

Interestingly I don't get that error if I serve the file locally

@enridaga
Copy link
Member

Just to make sure, Turtle and SPARQL are not the same when it comes to prefix declarations.
The following is not valid Turtle:

PREFIX fx: <http://sparql.xyz/facade-x/ns/>

<a> <b> <c> .

while this should be:

@prefix fx: <http://sparql.xyz/facade-x/ns/> .

<a> <b> <c> .

Is that your problem?

@cristianvasquez
Copy link
Author

Sorry, I tried to isolate the problem but I made a mistake :)

The file that failed was the following: https://raw.githubusercontent.com/SEMICeu/BregDCAT-AP/refs/heads/main/releases/2.1.0/BRegDCAT-AP_shacl_shapes_2.1.0.ttl

With query:

PREFIX xyz: <http://sparql.xyz/facade-x/data/>
PREFIX fx: <http://sparql.xyz/facade-x/ns/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>

SELECT *
WHERE {
  SERVICE <x-sparql-anything:> {
    fx:properties
      fx:location "https://raw.githubusercontent.com/SEMICeu/BregDCAT-AP/refs/heads/main/releases/2.1.0/BRegDCAT-AP_shacl_shapes_2.1.0.ttl" ;
      fx:media-type "text/turtle" .
?s ?p ?o .
  }
}

@enridaga
Copy link
Member

OK, I see the problem. With 5c42c1f#diff-2216d69f6038f63ffb0a2cd69a77bb2f83c7d4e4be758c0ef17d774a0a50afbaR60 we added the media type as a way to detect the correct RDF language BUT, this only happens after checking the HTTP Content-Type declaration. Instead, we should always assume that the media type configured gets precedence. In your case, the returned Content-Type is text/plain, which is mapped to NT by Jena RIOT. Reopening.

@enridaga enridaga reopened this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants