You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Andy Seaborne (JIRA)" <ji...@apache.org> on 2014/07/04 13:06:33 UTC
[jira] [Commented] (JENA-740) SPARQL replace
[ https://issues.apache.org/jira/browse/JENA-740?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14052354#comment-14052354 ]
Andy Seaborne commented on JENA-740:
------------------------------------
Errors are legitimate extension points in SPARQL. This is coupled by the fact that F&O errors cause the whole XPath/XQuery execution to abort while in SPARQL it causes unbound variables or FILTERs being false. The overall SPARQL query still has results.
A more useful functionality might be to return a single {{"x"}} -- that is a single match -- by skipping empty string replacements after the first.
> SPARQL replace
> --------------
>
> Key: JENA-740
> URL: https://issues.apache.org/jira/browse/JENA-740
> Project: Apache Jena
> Issue Type: Improvement
> Components: ARQ
> Affects Versions: Jena 2.11.2
> Reporter: Andy Seaborne
> Priority: Minor
>
> [users@ email report "Replace doesn't error on patterns that match zero length strings"|http://mail-archives.apache.org/mod_mbox/jena-users/201407.mbox/%3CCA%2BQ4Jn%3DqOS85yCPGexqX%2BLFkX4Dw8QSQmBLq2kT05%2Btvj0xksA%40mail.gmail.com%3E].
> {{replace("abc", ".*", "x")}} returns {{"xx"}} because it uses Java's Matcher.replaceAll - it's one match for the whole of "abc" (it's a greedy pattern) and one match for the trailing empty string. Java returns {{"x"}} for an empty string, and {{"xx"}} for any non-empty string in place of "abc".
> F&O calls out this case and makes it an error.
> http://www.w3.org/TR/xpath-functions/#func-replace
> {quote}
> An error is raised \[err:FORX0003\] if the pattern matches a zero-length string, that is, if the expression fn:matches("", $pattern, $flags) returns true. It is not an error, however, if a captured substring is zero-length.
> {quote}
--
This message was sent by Atlassian JIRA
(v6.2#6252)