[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Including markup in a replace string
Yes if you can use analyze-string: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"> <xsl:output method="xml" encoding="UTF-8"/> <xsl:template match="/"> <body> <xsl:analyze-string select="'my text has {{ many curly }} braces lots more {{ than }} I expected'" regex="{'\{\{|\}\}'}"> <xsl:matching-substring> <span class="noProcess"> <xsl:value-of select="."/> </span> </xsl:matching-substring> <xsl:non-matching-substring> <xsl:value-of select="."/> </xsl:non-matching-substring> </xsl:analyze-string> </body> </xsl:template> </xsl:stylesheet> outputs <body>my text has <span class="noProcess">{{</span> many curly <span class="noProcess">}}</span> braces lots more <span class="noProcess">{{</span> than <span class="noProcess">}}</span> I expected </body> Heiko > Hi All, > I have code examples in some doc that are post processed in AngularJS. > In some cases the code examples include "{{" or "}}" which is > significant to Angular. I have a simple replace that I am using to wrap > a no-process span around the curly braces so the Angular process will > ignore them. > > <xsl:value-of select="replace(.,'(\{\{|\}\})','<span > class="noProcess">$1</span>')"/> > > The only problem is that the character entity is being output as a > character entity instead of less-than and greater-than characters. > > Is there a way to trick replace into outputting the less-than and > greater-than characters? > > I've tried entering the actual characters - doesn't work. I've tried > escaping the characters with backslashes - doesn't work either. > > So unless there's a way to trick replace I'll have to try analyze-string > and see if I can get what I need there. > > Thanks, > Craig > > Here's an example of what I need: > > <span class="noProcess">{{</span>This variable<span > class="noProcess">}}</span>
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|