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

Using XSL variable in XQuery regular expression

Subject: Using XSL variable in XQuery regular expression
From: <mlcook@xxxxxxxxxx>
Date: Thu, 16 Dec 2010 13:30:41 -0500
 Using XSL variable in XQuery regular expression
Dear List,

Is it possible to use an XSL variable in a regular expression when using the
"matches" function in an XSL transformation?

Say I have
<xsl:variable name="Prefix" as="xs:string" select="'PR'"/>

Then I want to use $Prefix in my regular expression like I might use XSL
variables elsewhere:
matches(normalize-space(text()[1]), '^(optional beginning text)*$Prefix:
[a-zA-Z ]*')

$ is a special character in regular expressions.  I haven't found examples of
variables in regular expressions in my internet searching.

I'd like to match text that starts with 'PR', such as "PR1234: Some problem to

I'd also like to match text that may have some other initial characters, then
the 'PR' prefix and more text, such as "optional beginning text PR9876:
Another problem".

I could put the literal 'PR' in the regular expression, but I was hoping to
factor that out for use in a few other regular expressions, and have only one
place to edit if the prefix string changed.

Thanks for suggestions, or letting me know this can't be done.

Mike Cook

This email and any attachments are only for use by the intended recipient(s)
and may contain legally privileged, confidential, proprietary or otherwise
private information.  Any unauthorized use, reproduction, dissemination,
distribution or other disclosure of the contents of this e-mail or its
attachments is strictly prohibited.  If you have received this email in error,
please notify the sender immediately and delete the original.

Current Thread


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.
First Name
Last Name
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.