zazuko / xrm

A friendly language for mappings to RDF
MIT License
1 stars 0 forks source link

csvw: Support null property #39

Closed mchlrch closed 4 years ago

mchlrch commented 4 years ago

Support null property as optional attribute of Referenceable (inside LogicalSource)

For null property see http://w3c.github.io/csvw/primer/#mixed-datatypes

Sample DSL snippet:

logical-source airport {
    type csv
    source "http://www.example.com/Airport.csv"

    referenceables
        id
        ownership "airport ownership" null "X"
        ownership null "X"
}

To clarify:

mchlrch commented 4 years ago

Sample DSL, using null in logical-source:

logical-source airport {
    type csv
    source "http://www.example.com/Airport.csv"

    referenceables
        id
        longitude null "N/A"
        ownership "airport ownership" null "X"
}

map AirportMapping from airport {
    subject template "http://airport.example.com/{0}" with id;

    types transit.Stop;

    properties
        wgs84_pos.long from longitude;
        ex.owner from ownership;
}

Generated CSVW output:

{
    "url": "http://www.example.com/Airport.csv",
    "tableSchema": {
        "aboutUrl": "http://airport.example.com/{id}",
        "columns": [
            {
                "virtual": true,
                "propertyUrl": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type",
                "valueUrl": "http://vocab.org/transit/terms/Stop"
            }
            ,
            {
                "propertyUrl": "http://www.w3.org/2003/01/geo/wgs84_pos#long",
                "titles": "longitude",
                "null": "N/A"
            },
            {
                "propertyUrl": "https://schema.example.org/owner",
                "titles": "airport ownership",
                "null": "X"
            }
            ,
            {
                "suppressOutput": true,
                "titles": "id"
            }
        ] 
    }
}