Hi Michael.

As you can see from my previous email, I do use Java API for XQuery, so I am a little bit confused – what do you mean when you say “Java side”?

Another question is how can I escape the special characters? For example, I tried the backslash symbol for escaping the quote mark, but it didn’t help.

Here the query term:

for $e in /*/*[string(.)='kuku?'] order by string($e) return $e

 

Here the exception details:

 

Error

  XQuery syntax error on line 1 in ``:

    Unexpected token "<eof>" in path expression

net.sf.saxon.xpath.XPathException$Static: XQuery syntax error

      at net.sf.saxon.query.QueryParser.grumble(QueryParser.java:173)

      at net.sf.saxon.expr.ExpressionParser.parseBasicStep(ExpressionParser.java:1163)

      at net.sf.saxon.expr.ExpressionParser.parseStepExpression(ExpressionParser.java:997)

      at net.sf.saxon.expr.ExpressionParser.parseRelativePath(ExpressionParser.java:968)

      at net.sf.saxon.expr.ExpressionParser.parsePathExpression(ExpressionParser.java:953)

      at net.sf.saxon.expr.ExpressionParser.parseUnaryExpression(ExpressionParser.java:849)

      at net.sf.saxon.expr.ExpressionParser.parseCastExpression(ExpressionParser.java:550)

      at net.sf.saxon.expr.ExpressionParser.parseCastableExpression(ExpressionParser.java:525)

      at net.sf.saxon.expr.ExpressionParser.parseTreatExpression(ExpressionParser.java:506)

      at net.sf.saxon.expr.ExpressionParser.parseInstanceOfExpression(ExpressionParser.java:488)

      at net.sf.saxon.expr.ExpressionParser.parseIntersectExpression(ExpressionParser.java:882)

      at net.sf.saxon.expr.ExpressionParser.parseUnionExpression(ExpressionParser.java:864)

      at net.sf.saxon.expr.ExpressionParser.parseMultiplicativeExpression(ExpressionParser.java:801)

      at net.sf.saxon.expr.ExpressionParser.parseAdditiveExpression(ExpressionParser.java:781)

      at net.sf.saxon.expr.ExpressionParser.parseRangeExpression(ExpressionParser.java:699)

      at net.sf.saxon.expr.ExpressionParser.parseComparisonExpression(ExpressionParser.java:650)

      at net.sf.saxon.expr.ExpressionParser.parseAndExpression(ExpressionParser.java:312)

      at net.sf.saxon.expr.ExpressionParser.parseOrExpression(ExpressionParser.java:295)

      at net.sf.saxon.expr.ExpressionParser.parseExprSingle(ExpressionParser.java:260)

      at net.sf.saxon.expr.ExpressionParser.parseExpression(ExpressionParser.java:223)

      at net.sf.saxon.query.QueryParser.parseQuery(QueryParser.java:80)

      at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:45)

      at net.sf.saxon.query.QueryProcessor.compileQuery(QueryProcessor.java:145)

      at com.sap.portal.utils.lat.query.SaxonQueryExecutor.execute(SaxonQueryExecutor.java:67)

      at com.sap.portal.utils.lat.query.LatQueryProcessor.run(LatQueryProcessor.java:50)

      at com.sap.portal.utils.lat.query.LatQuery.execute(LatQuery.java:59)

      at com.sap.portal.utils.lat.query.LatQuery.main(LatQuery.java:153)

 

So, can you please, clarify these issues?

 

Thank you.

            Irena.

 


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Michael Kay
Sent: Tuesday, October 05, 2004 5:08 PM
To: saxon-help@lists.sourceforge.net
Subject: RE: [saxon] spesial characters in query

 

The only characters that should need special treatment inside a string literal are the quote mark used as the string delimiter, and ampersand. These characters must be escaped. There's nothing special about backslash, *, etc, so I suspect that the problem is on the Java side and not the XQuery side.

 

Michael Kay

 


From: saxon-help-admin@lists.sourceforge.net [mailto:saxon-help-admin@lists.sourceforge.net] On Behalf Of Kofman, Irena
Sent: 05 October 2004 15:41
To: saxon-help@lists.sourceforge.net
Subject: [saxon] spesial characters in query

Hello!

If I try to compile a query that looks like:

 

 

      Query = “for $e in /*/*[string(.)='"+searchString+"'] order by string($e) return $e”;

      XQueryExpression exp = xquery.compileQuery(Query);

 

And searchString contains characters like ‘,\,* and some more, I get exceptions.

What can I do about it?

      Thank you

            Irena