Search

Hi,

can sb. give me an example for exslt - str.replace

How can it be included, What could be done with this?

Is this str.replace an output filter, e.g. if I want to replace all strings in my “value-of” like “###ABC###” with “hello symphony” ?

PHPINFO says I have exslt enabled. EXSLT enabled libexslt Version 1.1.24

Thanks for your “howto” in advance.

Thomas.

The doc page says

No XSLT processors that we know of have built-in support for str:replace.

You won’t be able to use this I’m afraid. But how about this XSLT utility?

Hi phoque, thats why I want to use the exslt str.replace. See URL above.

Function Syntax

node-set str:replace(string, object, object)

Template Syntax

<xsl:call-template name="str:replace">
   <xsl:with-param name="string" select="string" />
   <xsl:with-param name="search" select="object" />
   <xsl:with-param name="replace" select="object" />
</xsl:call-template>

Could this be the function we were waiting for?

I use str.replace.template.xsl (i.e. the template, not the function — I had problems with the latter) on several sites. I simply include the file, then use it like this (Ninja-style):

<xsl:template match="text() mode="html">
    <xsl:call-template name="str:_replace">
        <xsl:with-param name="string" select="."/>
        <xsl:with-param name="replacements" select="exsl:node-set($replacements)/replacement"/>
    </xsl:call-template>
</xsl:template>

As you see, I pass a node-set — I can even use HTML and dynamic replacement values from my XML in this node-set:

<xsl:variable name="replacements">
    <replacement search="lalala"><em class="lalala">new text</em></replacement>
    <replacement search="[[huiui]]">
        <xsl:value-of select="xml-huiui-value"/>
    </replacement>
</xsl:variable>

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details