I am very new to XSLT and need to grab only the last letter of an XML value and add that character to my HTML output.
XSLT doesn't have any new function to search Strings in a reverse manner. We have substring function which creates two fields substring-before-last and substring-after-last.In XSLT it is defined as follows: <xsl:value-of select="substring (string name ,0, MAX_LENGTH )"/>...
XSLT <xsl:value-of> Element The <xsl:value-of> element is used to extract the value of a selected node.
Concat function in XSLT helps to concatenate two strings into single strings. The function Concat() takes any arguments that are not the string is been converted to strings. The cardinality function passed over here in each argument should satisfy zero or one function() respectively.
XSLT uses the <xsl:output> element to determine whether the output produced by the transformation is conformant XML (<xsl:output method="xml"/> ), valid HTML (<xsl:output method="html"/> ), or unverified text (< xsl:output method="text"/> ).
Use the XPath expression
substring(., string-length(.), 1)
or, in an XSLT way
<xsl:value-of select="substring(., string-length(.), 1)" />
This works, because XPath starts counting at 1 and not 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With