Skip to content

access file in zip: mixup absolute/relative url #335

@VladimirAlexiev

Description

@VladimirAlexiev

This script (same as in #334) opens an archive (https://sparql-anything.readthedocs.io/en/latest/Configuration/#from-archive) and rdfizes files from it:

### rdfize-zip.sparql
# rdfize an archive (zip) of files. parameter values:
# -v zip: zip filename or URL
# -v file: file regexp pattern (default ~.*~)
# sparql-anything -q ../rdfize-zip.sparql -v zip=graphql-2023-01-24.zip > raw-rdf.ttl

prefix bsdd: <http://bsdd.buildingsmart.org/def#>
prefix xyz:  <http://sparql.xyz/facade-x/data/>
prefix fx:   <http://sparql.xyz/facade-x/ns/>
prefix rdf:  <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
prefix xsd:  <http://www.w3.org/2001/XMLSchema#>

construct {
  ?s ?p ?o
} where {
  service <x-sparql-anything:> {
    bind(coalesce(?__file,".*") as ?pattern)
    fx:properties fx:location ?_zip.
    fx:properties fx:archive.matches ?pattern.
    [] fx:anySlot ?file
    service <x-sparql-anything:media-type=application/json> {
      bind(str(bsdd:) as ?bsdd)
      fx:properties fx:namespace ?bsdd.
      fx:properties fx:location ?file.
      fx:properties fx:from-archive ?_zip.
      fx:properties fx:use-rdfs-member true.
      ?s ?p ?o
    }
  }
}

fails with the following error:

[main] ERROR com.github.sparqlanything.engine.FacadeXOpExecutor - An error occurred: 
java.io.FileNotFoundException: 
tmp\cd81ed69fe4de812bb3928afd960e85d\http:\sparql.xyz\facade-x\ns\root 
(The filename, directory name, or volume label syntax is incorrect)

[main] ERROR com.github.sparqlanything.cli.SPARQLAnything - Iteration 1 failed with error: 
java.io.IOException: java.io.FileNotFoundException:
 tmp\cd81ed69fe4de812bb3928afd960e85d\http:\sparql.xyz\facade-x\ns\root 
(The filename, directory name, or volume label syntax is incorrect)

I see two problems here:

  • forward slashes in fx: are replaced with backward slashes. Maybe that comes from Windows/Cygwin
  • the absolute URL fx:root is appended to tmp\cd81ed69fe4de812bb3928afd960e85d: WHY?
    • Notice that I set fx:namespace, but to a different namespace: to rename xyz -> bsdd (BSDD is the data we're working with)

Metadata

Metadata

Assignees

Labels

BugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions