kasei / perlrdf

Deprecated in favor of the Attean package
26 stars 25 forks source link

Add support for saving base URI declarations in RDF::Trine::NamespaceMap and parsers/serializers #131

Open kasei opened 9 years ago

kasei commented 9 years ago

Discussed in the comments of #130.

VladimirAlexiev commented 9 years ago

Not just to save @base but also to use in abbreviate. Eg

 my $map     = RDF::Trine::NamespaceMap->new();
 my $parser  = RDF::Trine::Parser->new('turtle', namespaces => $map);
 $parser->parse_file_into_model( $base, \*DATA, $model, namespaces => $map );
    # can it feed from filehandle?

 use feature 'say';
 say $map->abbreviate('http://museum1.org/object/BCR187052');    # <object/BCR187052> # uses base
 say $map->abbreviate('http://museum2.org/object/BCR187052');    # :object/BCR187052  # uses empty prefix. Slash in CURIE. THIS IS NOT VALID Turtle but nice for printing examples
 say $map->abbreviate('http://museum3.org/object/BCR187052');    # <http://museum3.org/object/BCR187052> # neither base nor prefix
 say $map->abbreviate('http://vocab.getty.edu/aat/');            # aat:              # empty local name
 say $map->abbreviate('http://vocab.getty.edu/aat/1234');        # aat:1234          # starting digit in CURIE. This is valid Turtle 1.1
 say $map->abbreviate('http://vocab.getty.edu/aat/contrib/456'); # aat_contrib:456   # longest prefix match

 __DATA__
 @base     <http://museum1.org/>.
 @prefix : <http://museum2.org/>.                    # Another Museum
 @prefix aat:         <http://vocab.getty.edu/aat/>. # Getty AAT
 @prefix aat_contrib: <http://vocab.getty.edu/aat/contrib/>.
VladimirAlexiev commented 7 years ago

Hi @kasei when could you fix this?