kg-construct / rml-io

RML-IO: Input/Output declarations for RML
https://w3id.org/rml/io/spec
Creative Commons Attribution 4.0 International
1 stars 4 forks source link

rml:Target: add more properties (write mode) #49

Closed ghsnd closed 3 months ago

ghsnd commented 6 months ago

For some targets it might make sense to specify some extra properties. I have this use case where I want to append output to target file x, but overwrite target file y if it exists. So for files there are the typical write modes, e.g. like the python file modes w, a, etc.

In the spec these properties might translate to properties that apply to other kinds of targets as well, for instance databases.

DylanVanAssche commented 6 months ago

Related to https://github.com/kg-construct/rml-core/issues/113

What about adding to rml:Target:

This property has the range of:

These semantics are derived from fopen():

     ``r''   Open text file for reading.  The stream is positioned at the
             beginning of the file.

     ``r+''  Open for reading and writing.  The stream is positioned at the
             beginning of the file.

     ``w''   Truncate to zero length or create text file for writing.  The
             stream is positioned at the beginning of the file.

     ``w+''  Open for reading and writing.  The file is created if it does not
             exist, otherwise it is truncated.  The stream is positioned at
             the beginning of the file.

     ``a''   Open for writing.  The file is created if it does not exist.  The
             stream is positioned at the end of the file.  Subsequent writes
             to the file will always end up at the then current end of file,
             irrespective of any intervening [fseek(3)](https://www.manpagez.com/man/3/fseek/) or similar.

     ``a+''  Open for reading and writing.  The file is created if it does not
             exist.  The stream is positioned at the end of the file.  Subse-
             quent writes to the file will always end up at the then current
             end of file, irrespective of any intervening [fseek(3)](https://www.manpagez.com/man/3/fseek/) or similar.

Source: https://www.manpagez.com/man/3/fopen/

If no access mode is provided, the file is opened in rml:Write mode for rml:Target.

Note: rml:Source does have rml:mode since it always open the source in read-only mode.