/************************************************************************
[49] GroupingSpec ::= "$" VarName ("collation" URILiteral)?
************************************************************************/
final public GroupingSpec parseGroupingSpec() throws ParseException, XQueryException {
final GroupingSpec spec;
currentToken = jj_consume_token(VariableIndicator);
currentToken = jj_consume_token(VarName);
String defaultNamespace = currentModule.getNamespace();
if(defaultNamespace == null) {
defaultNamespace = "";
}
QualifiedName vn = QNameUtil.parse(currentToken.image, namespaceContext, defaultNamespace);
Variable var = currentModule.getVariable(vn);
if(var == null) {
error("err:XPST0008");
}
if(!(var instanceof ForVariable || var instanceof LetVariable)) {
error("err:XQST0094");
}
BindingVariable bindingVar = (BindingVariable) var;
spec = new GroupingSpec(bindingVar);
locate(spec);
switch(jj_nt.kind) {
case Collation:
// ("collation" URILiteral)?
currentToken = jj_consume_token(Collation);
currentToken = jj_consume_token(URILiteralToOperator);
String collation = unquote(currentToken.image);
if(collation != null) {
try {
URI url = new URI(collation);
spec.setCollation(url);
} catch (URISyntaxException e) {
error("err:XQST0046");
}
}
break;