Subject:Java exception when apply regular expression Author:Jack Tan Date:28 Feb 2007 07:36 PM
I tested a small XQUERY program in the Stylus Studio 2006 Enterprise, build 653g.
In the scenarion using internal XQUERY processor all went smoothly. When switched to Saxon 8.7.1 it reports error:
error 719, FORX0002: Errot at character 1 in regular expressio "\x11|\\n" invalid escape sequence.
the offended line is:
...
fn:replace($var/name,"\x22|\\n"," ")
...
I simply want to replace "" and new lines in a string.
Why Saxon differs from the internal processor? What is wrong?
any pointers to relevant documentation suummarizing a correct course of action?
Subject:Re: Java exception when apply regular expression Author:(Deleted User) Date:06 Mar 2007 03:07 AM
Hi Jack,
the syntax of the regular expressions used in XQuery and XSLT is
described in the specs
(http://www.w3.org/TR/xpath-functions/#regex-syntax) that in turn is
based on the syntax described by the XMLSchema specs
(http://www.w3.org/TR/xmlschema-2/#regexs). There it's explained that
the only characters that need to be escaped are new lines, tab, and
the special characters \|.-^?*+{}()[].
This means that the regex you are specifying is: "|\n
As you need to insert this string inside an XQuery string literal,
you can choose to wrap it inside single quotes ('"|\n') or double
quotes, escaping the quote by duplicating it ("""|\n").
This is the official regex syntax, that both processor supports; the
internal processor also allows the usage of the syntax \xAA to
represent characters, but that is an implementation-specific extension.