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

Re: Including markup in a replace string (follow-up)

Subject: Re: Including markup in a replace string (follow-up)
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 6 Oct 2016 15:43:24 -0000
Re:  Including markup in a replace string (follow-up)
>   In my first post I asked if there was a way to trick the replace function
so I could output markup in the replacement string. I have since solved my
problem using xsl:analyze-string. I thought Ibd post the solution since it
involved escaping the curly braces that I was looking for.
>
> Herebs a snippet of the input string. Itbs from a test file so the text
is bogus:
>
>    datalines;
>       {{This variable}} is the catbs meow
>
> And herebs the analize-string I used to get the results I needed:
>
>   <xsl:analyze-string select="." regex="([{{]{{2}}|[}}]{{2}})">

The doubling is because curly brackets are special in XSLT attribute value
templates. The square brackets are because curly brackets are special in
regular expressions (to match "{" the regex needs to be either "\{" or
"[{]".)

I would probably write this one as

<xsl:variable name="regex">\{\{|\}\}</xsl:variable>
<xsl:analyze-string regex="{$regex}">...

Michael Kay
Saxonica

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.