xslt condition for multiple line of text column - xslt

i am having one issue in displaying description column data from the list in data view web part.Actually in my list i've a column named as Description type of this column is multiple line of text what i want if length of the text in description column is greater than 20 characters than display only 20 characters otherwise show all characters. I've written the following xslt to do that.
<xsl:choose>
<xsl:when test="string-length(#Description) > 20">
<xsl:value-of select="substring(#Description, 1, 20)" />...
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="#Description" disable-output-escaping="yes"/>
</xsl:otherwise>
</xsl:choose>
Same thing is working for the column whose type is single line of text,can anyone tell me how to achieve this for the column whose type is multiple line of text

Related

XSLT How to substring after 10 characters

I use xslt to substring before:
<xsl:element name="mapcat">
<xsl:value-of select="substring-before(categories,'/')"/>
</xsl:element>
Original:
17845/288323/8844
Result:
17845
Working correct
Now I need substring after 10 characters.
I try:
<xsl:element name="mapcat">
<xsl:value-of select="substring(categories,'1,10')"/>
</xsl:element>
But something went wrong and no working. Can anyone help me correct this code?
I need substring after 10 characters.
I am guessing you want to do:
<xsl:value-of select="substring(original-string, 11)"/>
Your explanation of the problem wasn't very clear (difficulties with your English perhaps?) but from the example supplied as a comment you want the first 11 characters of the string, which is substring(xx, 1, 11). Supplying 0 (or anything less than 1) as the second argument has the same effect: the actual semantics of substring(x, a, b) are to include all characters in x whose position p (counting from 1) satisfies p>=a and p<(a+b) -- with additional rules for rounding if the values are not integers.

XSLT code to select string between first underscore until third underscore(will be cut after 10 digits)

current Output
<wd:GradeCode>CH_Service_Fly_test worker</wd:GradeCode>
<wd:GradeCode>CN_Dips_12 Engineer depart</wd:GradeCode>
Output needed
<wd:GradeCode>Service_Fl</wd:GradeCode>
<wd:GradeCode>Dips_12 En</wd:GradeCode>
Unfortunately little input. Which could probably work, would be the following function (depending on what you have in mind):
<!-- build a string after the first underline -->
<xsl:variable name="firstString">
<xsl:value-of select="substring-after(., '_')"/>
</xsl:variable>
<!-- limit the firstString to 10 digits -->
<xsl:value-of select="substring($firstString/text(),1,10)"/>
The pending to use for each item.

How would I substring my value 6 decimal places

Is there a way to substring my value 6 places after decimal?
So if I have
<xsl:value-of select="100.1234567890" />
Is there a way to make it
"100.123456"
Your value is a number, not a string. The easy way to trim it to 6 decimal places is to floor it, not substring it:
<xsl:value-of select="floor(100.1234567890 * 1000000) div 1000000"/>
returns:
100.123456
To achieve the same thing through string manipulation, you could do:
<xsl:variable name="n" select="'100.1234567890'" />
<xsl:value-of select="substring($n, 1, string-length(substring-before($n, '.')) + 7)"/>

Regex to find multi line match by negating a word

I have the below code
BLOCK 1
</config>
<pd:inputBindings>
<xmlString>
<xsl:value-of select="$JMS-Queue-Receiver/ns:ActivityOutput/Body"/>
</xmlString>
</pd:inputBindings>
</pd:activity>
<pd:activity name="Checkpoint">
BLOCK 2
</config>
<pd:inputBindings>
<Telegence>
<xsl:for-each select="$Start/group/CHANGE_MDN">
<CHANGE_MDN>
<EVENT_TYPE>
i'm using the regex to select the from the BLOCK 2 ,
<pd:inputBindings>
<Telegence>
if we see the block 1 below we have the same set of items,
<pd:inputBindings>
<xmlString>
so i want to select the block 2 piece based on the next line , if we see the block 1 we have <xsl:value-of , so we should not select from the block 1. if we see the block 2 we have <xsl:for-each so that needs to be select.
So i want to select by negating the <xsl:value-of .
i tried with the below regex but it selects both the blocks.
<pd:inputBindings>[\r\n <]+[[:word:]]+>[\r\n <]+(?!xsl:value-of)

Determine position of row in xslt is every 10th position

here is my current xslt:
<xsl:when test="position()=10">
This works, but i have 100 records so it only produces my neccessary html on the 10th record, and nothing more.
what i need now is a dynamic way of saying when is every ten positions. i imagine you could use modulus but im having difficulty getting that to work.
Ive tried:
<xsl:when test="position() mod 10">
Not sure what the solution is.
I think you want <xsl:when test="position() mod 10 = 0">.