Common Xslt function

08/12/2012 11:13

Starts-With

if url starts with http

<xsl:when test="starts-with('https://www.google.com','http')">

...

</xsl:when>

 

Replace text using translate(inText, what, with)

title is node value

{token} - text to replace

$days is variable

normalize-space is used to trim text

 

<xsl:value-of select="normalize-space(translate(title,'{token}',$days))"/>

 

BE CAREFUL HERE, IT'S NOT STANDARD REPLACEMENT. IF YOU WANT TO USE TOKEN, USE CHARACTER WHAT IS NOT USED IN TEXT, E. G. #, because some characters of text can disappear when are present in token.
 

 

 

Count

count($Rows) or

<xsl:value-of select-"count(dsQueryResponse/Rows/Row)"/>

Result: 6

 

Concat

Concat('a', '_b', '_some text)

a_b_some text

 

 

<?xml version="1.0" encoding="utf-8"?>
<dsQueryResponse>
  <Rows>
    <Row Title="E_Blog1"/>
    <Row Title="A_Blog2"/>
    <Row Title="D_Blog3"/>
    <Row Title="B_Blog4"/>
    <Row Title="C_Blog5"/>
    <Row Title="F_Blog6"/>
  </Rows>
</dsQueryResponse>