Git Product home page Git Product logo

xsparql's Introduction

README XSPARQL

Prerequisites

You will need at least:

The central Apache Maven repository contains almost all dependencies of XSPARQL. Because of licensing issues the following dependencies have to be downloaded manually and installed to your local maven repository:

  • The Saxon XSLT and XQuery Processor from Saxonica Limited, download from http://www.saxonica.com/ if you have a license for Saxon EE you can use saxon9-ee.jar otherwise the home edition (HE) is enough (saxon9.jar)

    Install the jar file in your local maven repository:

    mvn install:install-file -DgroupId=net.sf.saxon -DartifactId=saxon -Dversion=9.3 -Dpackaging=jar -Dfile=<path-to-jar-file>

Building XSPARQL

In the main xsparql directory (where you probably found this README) run maven with the install goal:

mvn install

When running the first time this will take some time since maven will download all the dependencies from the central repository.

OPTIONAL

If you want to use Graphviz to visualize a syntax tree download it from

http://www.graphviz.org/

or from a repository if available for your platform. Don't forget to set the path accordingly if not already done by the installation procedure.

You will also need a directory called ./tfd for the dot files and the generated files.

Running XSPARQL

You can run xsparql from the the created jar file:

java -jar lang/target/lang-0.2-jar-with-dependencies.jar query.xs

To get an overview of the possible parameters of xsparql execute

java -jar lang/target/lang-0.2-jar-with-dependencies.jar -h

You can also assign values to variables declared as external using an equals sign ($graph in this example):

java -jar lang/target/lang-0.2-jar-with-dependencies.jar query.xs graph="file:///home/user/graph.rdf"

Further documentation

xsparql's People

Contributors

patzomir avatar vladimiralexiev avatar zacharywhitley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

xsparql's Issues

How to capture piece of XML to a literal as is?

@nunolopes and @stefanbischof and @zacharywhitley is it possible to use XSPARQL to capture XML in a literal as is?

I have an XML file with stuff like this:

      <plu:geometry>
        <gml:Polygon srsName="http://www.opengis.net/def/crs/EPSG/0/25833" srsDimension="2">
          <gml:exterior>
            <gml:LinearRing>
              <gml:posList>385919.31860777 5824690.697477636 ...</gml:posList>
            </gml:LinearRing>
          </gml:exterior>
        </gml:Polygon>
      </plu:geometry>

and I want to capture it as a GeoSPARQL literal like this:

  <{$geo}> a geo:Geometry; geo:asGML {$parcel/plu:geometry}^^geo:gmlLiteral.

However it omits the XML elements and only captures the text content:

<https://graphdb.accordproject.eu/resource/tegel/_bp_ueberbaubaregrundstuecksflaeche.49/geo> geo:asGML  """

              385640.0017969721 5824886.201519095 ...



      """^^geo:gmlLiteral .

I tried without declare option saxon:output "method=text"; but it's even worse (the URLs are mangled):

&lt;https://graphdb.accordproject.eu/resource/tegel/_bp_ueberbaubaregrundstuecksflaeche.48/geo&gt; geo:asGML  """



              385640.0017969721 5824886.201519095 ...



      """^^geo:gmlLiteral .

Asked on twitter: https://twitter.com/valexiev1/status/1744256929189318851

grammar doesn't support embedded XML

Consider this script:

declare option saxon:output "method=text";
let $xml := 
<LOUFile>
  <DownloadURL>ftp://ftp.gmeiutility.org/20161121T025453.zip</DownloadURL>
  <ContentDate>2016-11-21T02:54:53.885Z</ContentDate>
  <Originator>EVK05KS7XY1DEII3R011</Originator>
  <RecordCount>229212</RecordCount>
  <ManagingLOUCount managingLOU="EVK05KS7XY1DEII3R011">229212</ManagingLOUCount>
  <SchemaValid>true</SchemaValid>
</LOUFile>
return $xml/DownloadURL
  • If I run it through xquery (saxon "query") it returns ftp://ftp.gmeiutility.org/20161121T025453.zip as expected
  • If I run it through xsparql, I get this error:
line 4:18 mismatched input ':' expecting ENDELM
line 4:74 no viable alternative at input '\r\n  '
Parse error: java.lang.Exception: Errors for Parser. Translation aborted.
java.lang.Exception: Errors for Parser. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:232)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)
  • Even if I remove the first two elements that include :, I still get this error:
line 5:15 extraneous input '229212' expecting ENDELM
line 6:55 extraneous input '229212' expecting ENDELM
line 7:15 extraneous input 'true' expecting ENDELM
Parse error: java.lang.Exception: Errors for Parser. Translation aborted.
java.lang.Exception: Errors for Parser. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:232)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

Guessing for URI

The program guesses wrong whether an object is to be inserted as URI.
Example:
"http:\my.com Link to my site" will be converted to <http:\my.com Link to my site>, thus making the output turtle file incorrect.

@base is omitted

A declared @base is not emitted in the output, so any relative URIs in construct{} end up incomplete

make a new release

hi @zacharywhitley !
As a first step towards #40, can you make a new release?

I diffed the latest release https://github.com/semantalytics/xsparql/releases/download/v1.1.0/xsparql-cli-jar-with-dependencies.jar against a local Jar that I have, and

cc @nataschake: this problem doesn't affect Accord effort, but watch this for the newest release

XSParql parsing fails if SPARQL query contains inner curly braces in UNION or OPTIONAL

declare namespace eli = "http://data.europa.eu/eli/ontology#";
<ELI xmlns:eli="http://data.europa.eu/eli/ontology#">
{
  for $LegalResource from <eli-data.ttl>
  where { 
  	$LegalResource a eli:LegalResource .
  	OPTIONAL { $LegalResource eli:in_force ?in_force . }
  }
  return 
  <LegalResource eli:URI="{$LegalResource}" />
}
</ELI>

Produces

line 4:2 mismatched input 'for' expecting LCURLY
line 6:3 mismatched input '$LegalResource' expecting LCURLY
line 7:14 mismatched input '$LegalResource' expecting LCURLY
line 9:2 mismatched input 'return' expecting ENDELM
line 11:16 no viable alternative at input ' '
Parse error: java.lang.Exception: Errors for Parser. Translation aborted.
java.lang.Exception: Errors for Parser. Translation aborted.
	at org.sourceforge.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:233)
	at org.sourceforge.xsparql.Main.rewriteQuery(Main.java:189)
	at org.sourceforge.xsparql.Main.main(Main.java:103)

This happens as soon as the "where" clause contains an inner pair of curly braces in an OPTIONAL or a UNION.

`bind` not allowed in `where` ???

declare function local:rdf_property ($property, $id as xs:string) {
  let $propName := $property/name()
  let $value    := $property/text()
  for $val where {
    bind(?value as ?val)
  }
  construct {<{$id}> <{$propName}> {$val}}
};

()

fails with

line 4:11 no viable alternative at input 'where'
line 5:4 mismatched input 'bind' expecting RCURLY

But according to https://rawgit2.com/VladimirAlexiev/xsparql/master/doc/grammar.xhtml#sparqlForClause, bind is allowed in where.
Commenting out the bind shows that is the selected grammar branch:

xsparql -a test.xsparql
....
              XSPARQL FOR from 4:6
              T_LET
                $_aux_results1
                T_FUNCTION_CALL
                  _xsparql:_sparqlQuery
                  T_PARAMS
                    T_FUNCTION_CALL
                      fn:concat
                      T_PARAMS
                        $_sparql_prefixes
                         SELECT $val
 where  {  }
                    deleteNode

What is going on?

rewriter doesn't allow union xpaths

This function

declare function local:rdf_outcome_small ($url as xs:string, $study) {
  if (not(fn:empty ($study/clinical_results/outcome_list))) then ()
  else for $i at $n in $study/(primary_outcome|secondary_outcome|other_outcome) ###
    let $outcome := fn:concat($url,"/outcome/",$n)
      construct {
        <{$url}> cto:outcome <{$outcome}>.
        <{$outcome}> a cto:Outcome;
          dc:type         {functx:capitalize-first(fn:substring-before($i/name(),"_outcome"))};
          dc:title        {$i/measure/text()};
          cto:timeFrame   {$i/time_frame/text()};
          cto:safetyIssue {func:boolean($i/safety_issue/text())};
          dc:description  {$i/description/text()}.
        }
};

causes this error

net/sf/xsparql/rewriter/XQuerySerializer.g: node from line 0:0 mismatched tree node: DOWN expecting <UP>
net/sf/xsparql/rewriter/XQuerySerializer.g: node from line 0:0 mismatched tree node: DOWN expecting <UP>
net/sf/xsparql/rewriter/XQuerySerializer.g: node from line 0:0 mismatched tree node: XPATH expecting <UP>
Parse error: java.lang.Exception: Errors for Serializer. Translation aborted.
java.lang.Exception: Errors for Serializer. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:257)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

(Both location and error message are totally useless, so god help you if you write in big chunks).

The culprit is the union xpath at ###. I'm no xpath expert, but according to http://www.freeformatter.com/xpath-tester.html that is valid.

(If I replace with $study/primary_outcome it goes ok, but I need the union!)

URL guessing is conceptually wrong

As #4 explains, XSPARQL tries to guess whether a term is a URL or literal. Such guessing is error-prone and completely unnecessary: it should know if something is a URL or not from the script, no guessing is necessary.

Eg consider this script

prefix ex: <http://example.org>
declare option saxon:output "method=text";

let $http := "http://this is a literal"
let $ftp := "ftp://this.is.url.com/"
let $url := "relative-URL"
construct {
  ex:subj ex:prop
    "http://this is a literal",
    $http,
    <{$http}>,
    <ftp://this.is.url.com/>,
    $ftp,
    <{$ftp}>,
    $url,
    <{$url}>.
}

The output is as follows

ex:subj  ex:prop  "http://this is a literal" . # OK
ex:subj  ex:prop  <http://this is a literal> . # NOK
ex:subj  ex:prop  <http://this is a literal> . # OK
ex:subj  ex:prop  <ftp://this.is.url.com/> . # OK
ex:subj  ex:prop  "ftp://this.is.url.com/" . # OK
ex:subj  ex:prop  ftp://this.is.url.com/ . # NOK and a syntax error
ex:subj  ex:prop  "relative-URL" . # OK
ex:subj  ex:prop  <relative-URL> . # OK

You see that the guessing makes two mistakes:

  • for $http it wrongly assumes a URL because it starts with http://
  • for <{$ftp}> it fails to emit a URL (because the guessing is incomplete, see #4) but fails to emit a literal either (because <...> indicates a URL)

Future of xsparql

@VladimirAlexiev @nunolopez It's nice to see some activity here. I've always thought that xsparql was a brilliant idea and have been disappointed that it hasn't gotten more interest from the community. I wanted to open this issue to see if we could have a discussion of why that is and what might move it forward.

`undef` is recognized, `UNDEF` is not

This script is parsed ok:

declare function local:rdf_property ($property, $id as xs:string) {
  let $propName := $property/name()
  let $value    := $property/text()
  for $prop $dt where {
    values ($propName1                    $prop                                $dt           ) {
      ("GF_Ausn"                          "xp:floorAreaExcluded"               "xsd:decimal" )
      ("nutzungsform"                     "xp:formOfUse"                       undef         )
    }
    filter ($propName1 = $propName)
  }
  construct {<{$id}> <{$prop}> {$value}} # ^^{$dt} 
};

()

But if I replace undef with UNDEF, I get this error:

line 4:12 no viable alternative at input '$dt'
line 5:4 mismatched input 'values' expecting RCURLY
  • The problem is that SPARQL is case-insensitive so UNDEF should also be accepted
  • Another problem is that the error message is totally unhelpful: the location is two levels up, and then some nodes away. I spent 2h debugging this (thinking that maybe it doesn't allow a second var in for. The xsparql parser is terrible that way :-(

rewriter gets confused by attribute named "count"

The following function

declare function local:rdf_milestones ($url as xs:string, $per as xs:string, $prop as xs:string, $elem as xs:string, $list) {
  for $i at $n in $list/*[name()=$elem]
  let $mil := fn:concat($per,"/",$prop,"/",$n)
    construct {
      <{$per}> cto:{$prop} <{$mil}>.
      <{$mil}> a cto:Milestone;
        dc:title {$i/title/text()}.
        {
          for $j at $m in $i/participants_list/participants
          let $part := fn:concat($mil,"/participants/",$m)
            construct {
              <{$mil}> cto:participants <{$part}>.
              <{$part}> a cto:ParticipantsCount.
              <{$part}> cto:count {$j/@count/string()}.  ####
              <{$part}> cto:group <{fn:concat($url, "/group/", $j/@group_id/substring(.,2))}>.
            }
        }
      }
};

Causes this error at the beginning of the function:

net/sf/xsparql/rewriter/XSPARQLRewriter.g: node from line 0:0 required (...)+ loop did not match anything at input 'T_FL
WOR'
net/sf/xsparql/rewriter/XSPARQLRewriter.g: node from line 374:15 mismatched tree node: in expecting T_QUERY_BODY
Parse error: java.lang.Exception: Errors for Rewriter. Translation aborted.
java.lang.Exception: Errors for Rewriter. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:240)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

The reason is the line marked ####: the rewriter gets confused by the attribute name count which it mistakes for a SPARQL keyword.

Workaround: rewrite the line to this ugly long-hand:

              <{$part}> cto:count {$j/attribute::*[name()="count"]/string()}.

What business the rewriter has inside that XPath, I do not know. It's very worrisome that it looks for SPARQL keywords inside an XPath.

May I also complain that the error messages from the rewriter (and their locations) are completely cryptic and unhelpful.

grammar doc doesn't show SQL querying

The doc grammars at https://github.com/semantalytics/xsparql/blob/master/doc/ do not show that XSPARQL can query RDBMS using SQL, something extremely useful and which is used to implement RDB2RDF DM and R2RML.
It starts with sqlForClause in the Antlr grammar XSPARQL.g.

Note: grammar.html is the source doc, and the others are derived from it:

  • grammar-nonterminals.ebnf, grammar.ebnf: plain text
  • grammar-nonterminals.xhtml, grammar.xhtml: railroad diagrams

Are there any other omissions in the doc grammars?

rewriter gets confused by element name "group"

this function

declare function local:rdf_groups ($url as xs:string, $study) {
  for $i in $study/clinical_results/baseline/group_list/group ###
  let $gr := fn:concat($url, "/group/", $i/@group_id/substring(.,2))
    # first char of @group_id is B=baseline, O=outcome, P=period, etc.
    # But the description is the same, so we identify them by the remaining numeric index
    construct {
      <{$url}> cto:group <{$gr}>.
      $gr a cto:Group;
        dc:title {$i/title/text()};
        dc:description {$i/description/text()}.      
    }
};

causes this error at the second line marked ###:

line 417:9 no viable alternative at input 'in'
line 417:56 no viable alternative at input 'group'
Parse error: java.lang.Exception: Errors for Parser. Translation aborted.
java.lang.Exception: Errors for Parser. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:232)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

Workaround: change it to this ugly longhand:

  for $i in $study/clinical_results/baseline/group_list/*[name()="group"]

how to use an OR path (disjunction)?

@nunolopez All of these alternatives

let $geom := $class/(position|raeumlicherGeltungsbereich)
let $geom := $class/position | $class/raeumlicherGeltungsbereich
geo:asGML {$class/(position|raeumlicherGeltungsbereich)}^^geo:gmlLiteral.

cause the following error:

net/sf/xsparql/rewriter/XQuerySerializer.g: node from line 0:0 mismatched tree node: DOWN expecting <UP>
Parse error: java.lang.Exception: Errors for Serializer. Translation aborted.
java.lang.Exception: Errors for Serializer. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:257)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

Disjunction (given eg as book/(chapter|appendix)/section) is allowed in both XPath 2.0 and 3.1:

SPARQL 1.1 support and status of the xsparql project

I came up to this XSPARQL implementation while looking for a way to translate big RDF files to XML.

I've tried it a bit and I understand that it doesn't support SPARQL 1.1 (e.g., I got an error for a property path + ZeroOrMorePath clause: ...WHERE {$Person a/rdfs:subClassOf* foaf:Person; ...}). I wonder if there are plans to update it and, in general, if the project is still maintained.

doesn't carry XSD types over to literals

If I create a XQuery value with a XSD type (eg xs:gYearMonth("2016-12")) I would expect the same datatype to be in the output (eg "2016-12"^^xs:gYearMonth) but only the plain literal is emitted.

In addition, I'd expect a boolean literal to be emitted as xsd:boolean (eg "true"^^xsd:boolean or true). But it's emitted as a plain string (eg "true").

Until this is fixed, is there a way for a function to return an appropriately formatted string, so the turtle output has the desired XSD datatype?

rewriter error messages are useless

This function

declare function local:rdf_measure ($url as xs:string, $base as xs:string, $meas as xs:string, $measure) {
  let $url := $url
  construct {
    <{$base}> cto:measure <{$meas}>.
    <{$meas}> a cto:Measure;  ###1
      dc:title          {$measure/title/text()};
      dc:description    {$measure/description/text()};
      cto:population    {$measure/population/text()};
      cto:units         {$measure/units/text()};
      cto:unitsAnalyzed {$measure/units_analyzed/text()};
      cto:param         {$measure/param/text()};
      cto:dispersion    {$measure/dispersion/text()};  ###2
      {
        for $i at $n in $measure/analyzed_list/analyzed return
          local:rdf_analyzed ($url, $meas, fn:concat($meas,"/analyzed/",$n), $i),
        for $i at $n in $measure/class_list/class return
          local:rdf_class    ($url, $meas, fn:concat($meas,"/class/",$n), $i)
      }
    }
};

causes the following error message at the line marked ### 1

line 492:4 no viable alternative at input '<{'
Parse error: java.lang.Exception: Errors for Parser. Translation aborted.
java.lang.Exception: Errors for Parser. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:232)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

The culprit is the line marked ### 2: should end in "." not ";"

The error messages are often cryptic, and the location info often useless. This makes writing xsparql a royal pain in the ass.

writing to STDOUT is inferior compared to writing to `-f`

I use the following JVM args to invoke xsparql (UTF-8 is important for proper Unicode handling):

java -Xmx6G -Dfile.encoding=UTF-8 -jar c:/prog/xsparql/xsparql-cli-jar-with-dependencies.jar ...

Writing to STDOUT is inferior compared to writing to -f file:

  • it mangles Unicode
  • prints out the Prova.txt crap (#41)

So one should always use -f to invoke xsparql, eg:

xsparql script.xsparql input=file.xml -f file.ttl

The inability to write properly to STDOUT is problematic if you want to post-process the output using a unix pipeline.
I tried this to no avail:

xsparql script.xsparql input=test.xml -f /dev/stdout > test1.ttl
File not found: script.xsparql

And this:

xsparql script.xsparql input=test.xml -f - > test1.ttl

It writes out ONLY the Prova.txt crap (Whaat?)

So I need to use a temp file in Makefile to do post-processing.

don't emit URI if part of it is null

If a xsparql triple has a fragment including this URL

     glei:{$f/clei:Originator/text()}

and the <clei:Originator> element is missing in a paricular XML instance,
xsparql creates a URI containing only the prefix glei:.

Instead, it should not make this URI at all (and consequently not make the triples involving this URL).

How to parse RDF input file

I am trying to convert RDF to XML. In my xsparql query I would like to take input RDF file as a arg from command line.

My xsparql query

`prefix obo: http://purl.obolibrary.org/obo/
prefix sio: http://semanticscience.org/resource/
prefix xsd: http://www.w3.org/2001/XMLSchema#
prefix snomedct: http://purl.bioontology.org/ontology/SNOMEDCT/
prefix rdf: http://www.w3.org/1999/02/22-rdf-syntax-ns#
{
for $dob from $inputFile
where {
$output rdf:type sio:SIO_000340.
$output sio:SIO_000300 $dob.

     $quality rdf:type obo:NCIT_C68615 .
     $quality sio:SIO_000642  $output.

     $person rdf:type sio:SIO_000498. 
     $person sio:SIO_000217 $quality .
   }
   
   return <ItemDataDateTime ItemOID="BRTHDTC">{$dob}</ItemDataDateTime>  

}

`

My command line

java -jar xsparql-cli-jar-with-dependencies.jar xsparql/cde-dob-to-odm.xsparql inputFile="file:///home/rajaram/work/ejp-rd/cde-mappings/cde-to-odm/xsparql/cde-dob-sex.ttl" -f output.xml

list of URL schemes is incomplete

A fully specified URI starting with <ftp://...> is emitted without the brackets, which causes RIOT error prefix ftp: is not defined.
URIs starting with <http://...> don't have this defect.
So the list of URI schemes that xsparql knows about is incomplete.
Check that it also covers mailto: etc

Workaround: xsparql-postprocess.pl:

#!perl -p
BEGIN {print "\@base <whatever you need here>\n"}
s{(ftp://[^ ]+)}{<$1>}g;

how to use WHERE VALUES for a lookup table?

@nunolopes
I want to use sparql VALUES for a lookup table because it's a lot handier than using a XML in-line structure.
But when I try this:

for $class in doc($input)/*/GML:featureMember/*[name() != "BP_Bereich"]
let $className := $class/name()
let $id        := fn:replace($class/@GML:id/string(),"^_","")

construct {
  <{$id}> a <{$classType}>
} where {
  values ($className $classType) {
    ("BP_BereichOhneEinAusfahrtLinie"                   xp:AreaWithoutEntryExitLine        )
    ("BP_UeberbaubareGrundstuecksFlaeche"               xp:BuildableArea                   )
    ("BP_AbweichungVonUeberbaubarerGrundstuecksFlaeche" xp:BuildableAreaDeviation          )
    ("BP_BauGrenze"                                     xp:BuildingBoundary                )
    ("BP_AbweichungVonBaugrenze"                        xp:BuildingBoundaryDeviation       )
    ("BP_BauLinie"                                      xp:BuildingLine                    )
    ("BP_BaugebietsTeilFlaeche"                         xp:BuildingSubArea                 )
    ("BP_GemeinschaftsanlagenFlaeche"                   xp:CommunityFacilitiesArea         )
    ("BP_FestsetzungNachLandesrecht"                    xp:DeterminationAccordingToStateLaw)
    ("BP_Immissionsschutz"                              xp:EmissionProtection              )
    ("BP_GruenFlaeche"                                  xp:GreenArea                       )
    ("XP_PTO"                                           xp:KeyPoint                        )
    ("BP_Plan"                                          xp:Plan                            )
    ("BP_AnpflanzungBindungErhaltung"                   xp:PlantingBindingConservation     )
    ("XP_PPO"                                           xp:Point                           )
    ("XP_TextAbschnitt"                                 xp:Regulation                      )
    ("BP_TextAbschnittFlaeche"                          xp:RegulationArea                  )
    ("BP_StrassenbegrenzungsLinie"                      xp:RoadBoundary                    )
    ("BP_SpezielleBauweise"                             xp:SpecialDesign                   )
    ("SO_Strassenverkehr"                               xp:TrafficArea                     )
    ("BP_NutzungsartenGrenze"                           xp:UseTypeBoundary                 )
  }
}

I get error

XPST0008: Variable $classType has not been declared
  • In SPARQL and in XSPARQL the CONSTRUCT clause comes first. So how can it use vars from WHERE (VALUES and BIND)??
  • The xsparql keyword WHERE is used in 4 contexts, but I can't figure out where to put it so I can use its vars in CONSTRUCT

Unicode bug

"μg" in XML is converted to \265g (octal code \265 followed by "g") which is invalid Unicode and causes this RIOT exception:

  org.apache.jena.atlas.RuntimeIOException: java.nio.charset.MalformedInputException: Input length = 1
        at org.apache.jena.atlas.io.IO.exception(IO.java:216)
        at org.apache.jena.atlas.io.CharStreamBuffered$SourceReader.fill(CharStreamBuffered.java:77)

"μ" in UFT8 is 2 bytes: \302\265. Somehow the XSPARQL conversion loses the first byte

>head -16 NCT01047553.xml |tail -1|od -c
0000120   y       D   o   s   e       o   f       1   8     302 265   g
0000140       (   9     302 265   g       T   w   i   c   e       D   a
0000160   i   l   y   )       i   n       J   a   p   a   n   e   s   e

>head -14 NCT01047553.ttl |tail -1|od -c
0000200   r   m   o   t   e   r   o   l       i   n       a       D   a
0000220   i   l   y       D   o   s   e       o   f       1   8     265
0000240   g       (   9     265   g       T   w   i   c   e       D   a

how to preserve BASE?

I want to use relative URLs for my subjects (who doesn't!). However:

XSPARQL just ignores them and doesn't output @base.

I post-process the output with this pipeline in Makefile:

%.ttl: xsparql.xsparql %.xml
	xsparql xsparql.xsparql input=$*.xml -f TEMP.ttl > /dev/null
	 riot --syntax ttl --formatted ttl --base "..." TEMP.ttl |\
	 perl -00e '@a=<>; print shift @a; print sort @a' > $*.ttl
	rm TEMP.ttl

It pretty-prints with riot while specifying the base, then finally sorts by "paragraph" (turtle clause)

merge AKSW fork to semantalytics trunk

@chile12 @jimkont: I just read at https://www.w3.org/community/rax/wiki/Draft_Material#XSPARQL:
"a fork of the original XSPARQL library at https://github.com/AKSW/xsparql (cleaning up some shortcomings, needs further testing...)".

I know about your script https://github.com/dbpedia/Cmdi-DataID-mappings/blob/master/CmdProfiles/OLAC-DcmiTerms/OLAC-DCTERMS-query.xs and am studying it for #12.

We started using XSPARQL more actively at Ontotext (eg RDFization of http://clinicaltrials.gov and GLEI), and if RDB & JSON conversion pans out fine, we'll make this our main RDFization tool.

I've opened a bunch of issues here and tweeted to the original developers, eg see https://twitter.com/valexiev1/status/816984263304376321, https://twitter.com/valexiev1/status/816634884047380480.

I hope it'd be possible to merge your fixes into this repo. Eg there is a grammar doc and I added railroad diagrams, but as #11 says, this doc already misses some features. You're fixing the grammar (need fake let before construct in functions), and these fixes are not reflected in the doc either.

Cheers!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.