rdf-ext / rdf-parser-csvw

CSV on the Web parser
MIT License
16 stars 4 forks source link

Wrong property when not all columns are suppressed or used #47

Closed tpluscode closed 4 weeks ago

tpluscode commented 2 years ago

I found that in a case when only a subset of columns are actually mapped, the default columns would not be output but instead a "random" predicate from the those mapped would be taken

This is because TableSchema#root was never actually set and thus this.dataset.match was called with a null parameter and returned an unexpected csvw:propertyUrl from whatever would be found.

The result would be similar to the below, where <http://schema.org/name> is used for all columns

<https://example.com/station/blBAS> <http://schema.org/identifier> "blBAS" .
<https://example.com/station/blBAS> <http://schema.org/name> "Basel-Binningen"@de .
<https://example.com/station/blBAS> <http://schema.org/name> "Basel-Binningen"@fr .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#aggregation_id> "annualmean" .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#canton> "ZH" .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#pollutant_id> "so2" .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#value> "31.9" .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#value_remark> "incomplete series" .
-<https://example.com/station/blBAS> <test032-mix-of-properties.csv#year> "1984" .
+<https://example.com/station/blBAS> <http://schema.org/name> "1984" .
+<https://example.com/station/blBAS> <http://schema.org/name> "31.9" .
+<https://example.com/station/blBAS> <http://schema.org/name> "ZH" .
+<https://example.com/station/blBAS> <http://schema.org/name> "annualmean" .
+<https://example.com/station/blBAS> <http://schema.org/name> "incomplete series" .
+<https://example.com/station/blBAS> <http://schema.org/name> "so2" .
_:c14n0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/csvw#TableGroup> .
_:c14n0 <http://www.w3.org/ns/csvw#table> _:c14n2 .
_:c14n1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/csvw#Row> .
_:c14n1 <http://www.w3.org/ns/csvw#describes> <https://example.com/station/blBAS> .
_:c14n1 <http://www.w3.org/ns/csvw#rownum> "1"^^<http://www.w3.org/2001/XMLSchema#integer> .
_:c14n1 <http://www.w3.org/ns/csvw#url> <test032-mix-of-properties.csv#row=2> .
_:c14n2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/ns/csvw#Table> .
_:c14n2 <http://www.w3.org/ns/csvw#row> _:c14n1 .
_:c14n2 <http://www.w3.org/ns/csvw#url> <test032-mix-of-properties.csv> .