RMLio / yarrrml-parser

A YARRRML parser library and CLI in Javascript
MIT License
43 stars 17 forks source link

Cannot use XML namespaces in XPath for subject generation #159

Closed rorlic closed 2 years ago

rorlic commented 2 years ago

Issue type: :bug: Bug

Description

Using a XML namespace in a subject definition will trim anything after and including the colon (:).

Steps

Consider the following YARRRML input:

prefixes:
  ex: http://earthquake.usgs.gov/
  dc: http://purl.org/dc/terms/

mappings:
  earthquake:
    sources:
      - [earthquake.xml~xpath, /ns:feed/ns:entry]
    s: ex:earthquake/$(./ns:id)#id
    po:
      - [a, ex:earthquake]
      - [dc:title, $(./ns:title)]

When generating the RML, there is an error in the RML for the subject.

Expected behavior: map:s_000 rdf:type rr:SubjectMap ; rr:template "http://earthquake.usgs.gov/earthquake/{./ns:id}#id" . Actual behavior: map:s_000 rdf:type rr:SubjectMap ; rr:template "http://earthquake.usgs.gov/earthquake/{./ns" .

Note that the source iterator (map:source_000 rml:iterator "/ns:feed/ns:entry" ;) and dc:title (map:om_001 rml:reference "./ns:title" ;) are produced correctly.

Note that in the RMLStreamer there is one example with a default XML namespace, but it has been commented out.

Environment

Using online Matey.

pheyvaer commented 2 years ago

Hi @rorlic

I will have a closer look when executing it locally but did you try escaping the second :? This results in ex:earthquake/$(./ns\:id)#id.

rorlic commented 2 years ago

Indeed, escaping the second : works great. I was not expecting that inside the $(...) definition, but it does make sense. Maybe this could be documented to make it clear?