RE: Regular Expressions in XQuery/XPath2

> In section 6.3.15.1 of the F&O spec, it says that:
> 
> "In string mode, the meta-character . matches any character 
> whatsoever. In 
> multi-line mode, the meta-character . matches any character 
> except a newline 
> character."
> 
> This seems to infer that in string mode, the meta-character . 
> should match the newline character. However, this behaviour 
> would differ from that of Regular Expressions in XML Schemas: 
> in appendix F of the XML Schema Datatypes spec the equivalent 
> character class for . is given as [^\n\r].
> 
> Can you please verify whether a newline should match the . 
> meta-character 
> in string mode? Is the newline character considered 'any character'?

Yes, you have read the spec correctly. 

The decision to diverge from XML Schema, and to instead adopt the Perl
conventions including the use of two different modes, wasn't made lightly.
In XML Schema, regular expressions are used only for performing boolean
tests on a string. In XSLT and perhaps also in XQuery, they will also be
used for more complex operations such as transforming multiple lines of text
into multiple element nodes. Some of the use cases required the us of the
text anchors $ and ^, which aren't supported in XML Schema, working in both
string mode and multi-line mode, and this in turn meant that the meaning of
"." needed to match the Perl definition.

Michael Kay

Received on Wednesday, 16 October 2002 21:13:52 UTC