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

rewriter gets confused by attribute named "count" #7

Open
VladimirAlexiev opened this issue Dec 5, 2016 · 1 comment
Open

rewriter gets confused by attribute named "count" #7

VladimirAlexiev opened this issue Dec 5, 2016 · 1 comment
Labels

Comments

@VladimirAlexiev
Copy link
Contributor

VladimirAlexiev commented Dec 5, 2016

The following function

declare function local:rdf_milestones ($url as xs:string, $per as xs:string, $prop as xs:string, $elem as xs:string, $list) {
  for $i at $n in $list/*[name()=$elem]
  let $mil := fn:concat($per,"/",$prop,"/",$n)
    construct {
      <{$per}> cto:{$prop} <{$mil}>.
      <{$mil}> a cto:Milestone;
        dc:title {$i/title/text()}.
        {
          for $j at $m in $i/participants_list/participants
          let $part := fn:concat($mil,"/participants/",$m)
            construct {
              <{$mil}> cto:participants <{$part}>.
              <{$part}> a cto:ParticipantsCount.
              <{$part}> cto:count {$j/@count/string()}.  ####
              <{$part}> cto:group <{fn:concat($url, "/group/", $j/@group_id/substring(.,2))}>.
            }
        }
      }
};

Causes this error at the beginning of the function:

net/sf/xsparql/rewriter/XSPARQLRewriter.g: node from line 0:0 required (...)+ loop did not match anything at input 'T_FL
WOR'
net/sf/xsparql/rewriter/XSPARQLRewriter.g: node from line 374:15 mismatched tree node: in expecting T_QUERY_BODY
Parse error: java.lang.Exception: Errors for Rewriter. Translation aborted.
java.lang.Exception: Errors for Rewriter. Translation aborted.
        at net.sf.xsparql.rewriter.XSPARQLProcessor.process(XSPARQLProcessor.java:240)
        at net.sf.xsparql.Main.rewriteQuery(Main.java:197)
        at net.sf.xsparql.Main.main(Main.java:111)

The reason is the line marked ####: the rewriter gets confused by the attribute name count which it mistakes for a SPARQL keyword.

Workaround: rewrite the line to this ugly long-hand:

              <{$part}> cto:count {$j/attribute::*[name()="count"]/string()}.

What business the rewriter has inside that XPath, I do not know. It's very worrisome that it looks for SPARQL keywords inside an XPath.

May I also complain that the error messages from the rewriter (and their locations) are completely cryptic and unhelpful.

@VladimirAlexiev
Copy link
Contributor Author

#8 is similar but concerns an element name

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants