Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider updating prefixes and base definitions and representations in SXP #20

Closed
gkellogg opened this issue Dec 6, 2021 · 1 comment
Labels
enhancement New feature or request

Comments

@gkellogg
Copy link
Collaborator

gkellogg commented Dec 6, 2021

Is your feature request related to a problem? Please describe.
Coming from SPARQL, if a sub-expression containing a URI with a lexical representation using a prefix or base definition is extracted, the to_sxp method will use that representation even if the prefix or base definition is no longer included.

Describe the solution you'd like
A method for managing prefix and base definition within an S-Expression (SPARQL-specific) which would recursively update the lexical representations of embedded URIs (including literal datatypes) would be nice.

# Possible refinements

# Adds a prefix declaration to an Array representation of an S-Exp and recursively update the lexical representations of contained URIs
def add_prefix(pfx, uri); end

# Adds a prefix declaration to an Array representation of an S-Exp and recursively update the lexical representations of contained URIs
def add_base(uri); end

# Returns a deep copy of an Array representation of an S-Exp without  the specified prefix and removes any lexical representations from included URIs recursively
def remove_prefix(pfx); end

# Returns a deep copy of an Array representation of an S-Exp without  the specified base and removes any lexical representations from included URIs recursively
def remove_base(); end

# Returns a deep copy of an Array representation of an S-Exp without any prefix or base declarations.
def clear_prefixes; end

# Return the prefix definitions from an an Array representation of an S-Exp
def prefixes; end

Additional context
See the email thread at https://lists.w3.org/Archives/Public/public-rdf-ruby/2021Dec/0014.html

@gkellogg gkellogg added the enhancement New feature or request label Dec 6, 2021
gkellogg added a commit that referenced this issue Dec 16, 2021
…se expressions and propgating to lower elements to create PNames when serializing only if appropriate.

Consolodates the contents of writer.rb into extensions.rb.
For #20.
@gkellogg
Copy link
Collaborator Author

This issue was settled without the described API changes. Instead, the signature of .to_sxp was changed to include keyword parameters prefixes and base_uri, which is propagated down. When RDF is included, the Array#to_sxp method looks to see if the array is of the form [:base _iri_ _expr_] or [prefix [['pfx:', _iri_], ...], _expr_] and extracts and passes the prefixes and base_uri parameters to recursive calls of _expr_.to_sxp.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

1 participant