[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: xslt 2.0 regex

Subject: Re: xslt 2.0 regex
From: davep <davep@xxxxxxxxxxxxx>
Date: Sat, 17 Mar 2012 18:01:22 +0000
Re:  xslt 2.0 regex
On 17/03/12 17:38, Brandon Ibach wrote:
Both XSLT 1.0 and 2.0 define variable names as QNames, so they *can*
have a ":" in them.

Agreed. My misread of the spec. Tks Brandon.

Ignoring that for the moment, though, Tony pointed out one consequence of this, but the bigger issue is that the "|" operator in regex is fairly low precedence, so you often need some parenthesis around the list of alternatives to get things right. Your NameStartChar.re has a hex-char-ref-encoded "$" at the beginning, so that regex is actually "$[A-Z] | _ | [a-z] | ...", which means it will match "(a dollar sign followed by an upper-case English letter) or (an underscore) or (a lower-case English letter) or ...".

Which is correct (less the missing :), that's what they call the startChar?



Actually, it might not even match that, since the "$" is a special character in regex, so you should escape it with a backslash to match it literally (though I think there are some rules which allow it to match literally even without the backslash, depending on what follows it, but best to be explicit).

+1.



All that said, I got this to work by dropping the "$" from the start of NameStartChar.re and changing Name.re to:

concat("\$(", $NameStartChar.re, ")(", $NameChar.re,")*")

-Brandon :)

presumably because $ is within the a-z grouping.... Yes it works.

It should be possible (and simpler) to use Tony's idea \i\c+ since : is a valid variable name. Not a syntax I've used before I think?


Wolfgang, I was copying the syntax from the xml rec, hence the groupings.





regards


--
Dave Pawson
XSLT XSL-FO FAQ.
http://www.dpawson.co.uk

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.