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

Re: XSLT Regex for Matching Curly Braces

Subject: Re: XSLT Regex for Matching Curly Braces
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Jun 2019 16:48:32 -0000
Re:  XSLT Regex for Matching Curly Braces
On 10.06.2019 18:30, Don Smith dsmith_lockesmith@xxxxxxxxx wrote:

I'm attempting to write a regex inB  XSLT on matching curly braces and
then produce the correct markup output. Between my lack of expertise in
regex generally and the special circumstances in XSLT with regard to
AVTs and curly braces I'm having little success.

The requirement is pretty straight-forward. Given a text node such as this:

} dui {elementum}. Potenti ullamcorper vitae tempus condimentum
dignissim facilisis arcu ligula {elementum} {
I want the output markup to be:

} dui<ph>elementum</ph>. Potenti ullamcorper vitae tempus condimentum
dignissim facilisis arcu ligula<ph>elementum</ph>{
So, two parts to my question:

1. What is the correct regex in XSLT to match a set of curly braces with
one or characters between them and no white space?

It all depends on where you put it.

2. Is <xsl:analyze-string> the best choice for processing the string via the regex and handling the output or is another approach preferred?

In XSLT 3 I think it is a bit easier using the analyze-string function and pushing the result through templates e.g. do

<xsl:apply-templates select="analyze-string(., '\{(\p{L}+)\}')"

for your text node and then

  <xsl:template match="match"
          <xsl:value-of select="group"/>

to handle the processing.

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.