Search

A new XSLT utility, “String utility functions” is now available for download. Comments and feedback can be left here but if you discover any issues, please post it on the issue tracker.

Oh, tasty! Now I feel stupid for using templates to implement string-replace. :-(

Great work. That remembers me old versions of Symphony that used sym namespace.

It makes XSL more accessible to “procedural programming” thinkers i guess. I like the fact that it reduces the amount of typing needed to to those kind of things. The fun part is that this way of using functions can be used for a lot more than these string functions…

The namespace bugged me at first, it puts such a “claim” on stuff but on the other hand, when more people are going to use this way of creating functions, the namespace is very needed!

Have you considered a more unobtrusive namespace such as string? In Form Controls I “claimed” the form namespace, so it feels like string would be more logical.

I didn’t thought of that, yet! I could start using the string namespace, but being such a “generic” name i fear the moments that more utilities will use the same namespace / function names…

On the other hand, the chance of this happening is not so great (at the moment).

I could start using the string namespace, but being such a “generic” name i fear the moments that more utilities will use the same namespace / function names…

Quick, be the first and grab it! All the other will either have to chose another one or ask you to merge their functions into your utility.

We should set up a ICANN-like Workinggroup for managing namespaces ;-)

String utility functions updated to version 1.01 on 16th of November 2010

@phoque: Done!

So when is the first meeting of the SCANS working-group (Symphony Community for Assigned Names and Spaces) ?? ;)

You missed it. SCANS had it’s yearly meeting yesterday on the Pandora, a nice motor yacht located in Cannes (France) at the moment. :-))

BTW: The “string” namespace has been given to Sandie Shaw. Sorry for that.

I’ve been thinking about your utiliy recently:

  1. Would you mind porting ´substring-count´ into your utility?
  2. I don’t like that I am able to set my own root- and entity-node in the string:split function. I’d rather transform the default <nodeset> and <node> into whatever else I like using XSLT. Allowing people to set as a function argument will only result in messy templates.

@michael-e: Darn, looks like i’m always missing out on those nice, funded black-ops working-groups! I have this feeling that Sandie Shaw is on that yacht as well, setting the mediterranean mood with song and rosé wine.

@phoque:

  1. No problem, substring-count is perfectly portable. I’ll try to get to porting it asap (first: deadlines!)
  2. The root and entity nodes are optional so you don’t have to use it. i have added it primarily to be able to create lists etc.

String utility functions updated to version 1.02 on 30th of November 2011

@phoque, I added that substring-count you asked for ... a year ago

Wise man say:

better late than never ;-)

If you are kind, please add a function for uppercase first letter. The idea comes from another string utility:

<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyzàèìòùáéíóúýâêîôûãñõäëïöüÿåæœçðø'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZÀÈÌÒÙÁÉÍÓÚÝÂÊÎÔÛÃÑÕÄËÏÖÜŸÅÆŒÇÐØ'" />

<!-- Convert string to lowercase -->
<func:function name="string:lower-case">
    <xsl:param name="in" />
    <func:result select="translate($in,$uppercase,$smallcase)" />
</func:function>

<!-- Convert string to uppercase -->
<func:function name="string:upper-case">
    <xsl:param name="in" />
    <func:result select="translate($in,$smallcase,$uppercase)" />
</func:function>

<!-- Convert first letter to uppercase -->
<func:function name="string:ucfirst">
    <xsl:param name="in" />
    <func:result>
        <xsl:copy-of select="string:upper-case(substring($in, 1, 1))" />
        <xsl:copy-of select="string:lower-case(substring($in, 2))" />
    </func:result>
</func:function>

String utility functions updated to version 1.03 on 1st of December 2011

@vladG I have added both capitalize (ucfirst) and capitalize-words.

Thanks!

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