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

Re: Re: Angle brackets and string manipulation

Subject: Re: Re: Angle brackets and string manipulation
From: Steve Rosenberry <Steve.Rosenberry@xxxxxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Mar 2003 14:41:02 -0500
xsl string substitution

Dimitre Novatchev wrote:
> 
> The "insert_breaks" template could create <br /> ***nodes*** -- not simply
> insert text.
>
> ...
> 
> Also do not define the xsl:variable "t1", but simply call the template 
> to produce its result.
> 
> ...
> 
> This [the above snipped version] is creating just text -- should 
> create a sequence of text nodes and "br" elements:
> 
>    <xsl:if test="contains($source_string,$marker)">
>     <xsl:value-of select="substring-before( $source_string, $marker )"/>
>     <br />
>      <xsl:call-template name="insert_breaks">
>        <xsl:with-param name="source_string" select="substring-after(
> $source_string, $marker )"/">
>        <xsl:with-param name="marker" select="$marker"/>
>      </xsl:call-template>
> 

Thanks, Dimitre.  I got the insert_breaks template to work with your
suggested snippet shown above to create nodes instead of just a text
string.  Indeed this was one of my early attempts.  The problem remains
that there is more than one substitution required, thus the reason for
variable, "t1".  I pass "t1" to the next substitution -- a simple string
substitution, no node creation -- and subsequently lose the <br />
element. 

After bustin' my head against the wall for another few hours with
various combinations of node-set() calls here and there, I decided to
take a look at EXSLT to see what the string library had implemented, and
Jeni did not let me down -- a full-blown replace any darn thing(s) with
any darn thing(s) 'til your heart's content.  Final version and an
example of using str:replace for multiple substitutions with both string
and element replacements:

<xsl:template match="text()">

  <xsl:call-template name="str:replace">
    <xsl:with-param name="string" select="." />
    <xsl:with-param name="search">
      <t>!br;</t>       <!-- node names are unimportant -->
      <t>!emdash;</t>
    </xsl:with-param>
    <xsl:with-param name="replace">
      <br />		<!-- replacements by position for above -->
      <t>&#151;</t>
    </xsl:with-param>
  </xsl:call-template>

</xsl:template>

Thanks again, Dimitri and Jeni.

-- 
Steve Rosenberry
Sr. Partner

Electronic Solutions Company -- For the Home of Integration
http://ElectronicSolutionsCo.com

(610) 670-1710

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.