index-of() function in XSL2
Hallo all,
I have recently completed an AJAX SOAP file and now I am trying to generate the XSL s from the functions that I have used in my script.
I have written an indexOf function which cuts a string from the beginning of an character stream "-- " and takes it as 100 characters. It is like
myArray7[i] = xmldoc.selectNodes("//fcs:folder/fcs:folderHeadlinesResultSet/fcs:folderHeadline/fcs:snippet")[i];
if(myArray7[i]==null){
return false;
}
else{
var cPos = myArray7[i].text.indexOf("-- ");
if (cPos >= 0)
snippet[i] = myArray7[i].text.substring(cPos + 3,100 + cPos + 3);
else
snippet[i] = myArray7[i].text.substring(0,100);
myCell1.innerHTML += "<p>"+snippet[i]+"...</p>";
}
What I tried to write in my XSL is:
<tr>
<xsl:variable name="snippet" select="fcs:snippet"/>
<xsl:variable name="cPos" select="index-of($snippet, '-')"/>
<xsl:choose>
<xsl:when test="$cPos >= 0">
<xsl:variable name="cutSnippet" select="substring($snippet,$cPos+3,100+$cPos+3)"/>
<td class="text"><xsl:value-of select="$cutSnippet"/></td>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="cutSnippet" select="substring($snippet,0,100)"/>
<td class="text"><xsl:value-of select="$cutSnippet"/></td>
</xsl:otherwise>
</xsl:choose>
</tr>
But it doesn't work. What am I doing wrong? Can anyone help me?
Your attitude determines your altitude
__________________
Your attitude determines your altitude
|