How to convert
01/29/2012 00:00
to
Monday, Jan 29, 2012
in xslt?
I. An XSLT 1.0 solution (not producing the day of the week), which is much simpler and shorter than other answers :
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:my="my:my">
<xsl:output method="text"/>
<my:months>
<m>Jan</m><m>Feb</m><m>Mar</m><m>Apr</m><m>May</m><m>Jun</m>
<m>Jul</m><m>Aug</m><m>Sep</m><m>Oct</m><m>Nov</m><m>Dec</m>
</my:months>
<xsl:variable name="vMonthNames" select=
"document('')/*/my:months/*"/>
<xsl:template match="text()">
<xsl:variable name="vnumMonth" select="substring-before(., '/')"/>
<xsl:variable name="vDay" select=
"substring-before(substring-after(., '/'), '/')"/>
<xsl:variable name="vYear" select=
"substring-before(substring-after(substring-after(., '/'), '/'), ' ')"/>
<xsl:value-of select=
"concat($vMonthNames[0+$vnumMonth], ' ',
$vDay, ', ',
$vYear
)"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following XML document:
<t>01/29/2012 00:00</t>
the wanted result is produced:
Jan 29, 2012
II.In XSLT 2.0 one can use very powerful date-time functions, such as format-dateTime().
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:template match="text()">
<xsl:variable name="vComps" select=
"tokenize(., '/')"/>
<xsl:variable name="vstdDate" select=
"concat(substring-before($vComps[3], ' '), '-',
$vComps[1], '-',
$vComps[2]
)"/>
<xsl:sequence select=
"format-date(xs:date($vstdDate), '[FNn], [MNn] [D], [Y]')"/>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the same XML document (above), the wanted, correct result is produced:
Sunday, January 29, 2012
Source : http://geekswithblogs.net/workdog/archive/2007/02/08/105858.aspx#110623
" I've modified to convert "1/20/2007 10:22:28 PM" to "January 20, 2007" ... to save anyone who finds it useful a few minutes.
<xsl:template name="FormatDate">
<!-- expected date format 1/20/2007 10:22:28 PM [OR] 01/20/2007 10:22:28 PM -->
<xsl:param name="DateTime" />
<!-- new date format January 20, 2007 -->
<xsl:variable name="mo">
<xsl:value-of select="substring-before($DateTime,'/')" />
</xsl:variable>
<xsl:variable name="day-temp">
<xsl:value-of select="substring-after($DateTime,'/')" />
</xsl:variable>
<xsl:variable name="day">
<xsl:value-of select="substring-before($day-temp,'/')" />
</xsl:variable>
<xsl:variable name="year-temp">
<xsl:value-of select="substring-after($day-temp,'/')" />
</xsl:variable>
<xsl:variable name="year">
<xsl:value-of select="substring($year-temp,1,4)" />
</xsl:variable>
<xsl:choose>
<xsl:when test="$mo = '1' or $mo = '01'">January</xsl:when>
<xsl:when test="$mo = '2' or $mo = '02'">February</xsl:when>
<xsl:when test="$mo = '3' or $mo = '03'">March</xsl:when>
<xsl:when test="$mo = '4' or $mo = '04'">April</xsl:when>
<xsl:when test="$mo = '5' or $mo = '05'">May</xsl:when>
<xsl:when test="$mo = '6' or $mo = '06'">June</xsl:when>
<xsl:when test="$mo = '7' or $mo = '07'">July</xsl:when>
<xsl:when test="$mo = '8' or $mo = '08'">August</xsl:when>
<xsl:when test="$mo = '9' or $mo = '09'">September</xsl:when>
<xsl:when test="$mo = '10'">October</xsl:when>
<xsl:when test="$mo = '11'">November</xsl:when>
<xsl:when test="$mo = '12'">December</xsl:when>
</xsl:choose>
<xsl:value-of select="' '"/>
<xsl:if test="(string-length($day) < 2)">
<xsl:value-of select="0"/>
</xsl:if>
<xsl:value-of select="$day"/>
<xsl:value-of select="', '"/>
<xsl:value-of select="$year"/>
</xsl:template>
"
Apologies for this horribly complicated solution, but it'll give you exactly what you want in XSLT 1.0:
<xsl:variable name="months" select="'JanFebMarAprMayJunJulAugSepOctDec'" />
<xsl:variable name="weekdays" select="'Monday Tuesday WednesdayThursday Friday Saturday Sunday '" />
<xsl:template match="date">
<xsl:variable name="days">
<xsl:value-of select="
((substring(.,7,4) - 1970) * 365)+floor((substring(.,7,4) - 1970) div 4)+
substring('000,031,059,090,120,151,181,212,243,273,304,334,365',substring(.,1,2)*4-3,3)+
(substring(.,4,2)-1)+
(1-floor(((substring(.,7,4) mod 4) + 2) div 3))*floor((substring(.,1,2)+17) div 20)
" />
</xsl:variable>
<xsl:value-of select="concat(
normalize-space(substring($weekdays,(($days+3) mod 7) * 9 + 1, 9)),
', ',
substring($months,substring(.,1,2) * 3 - 2, 3),
' ',
substring(.,4,2) + 0,
', ',
substring(.,7,4)
)" />
</xsl:template>
The construction of the variable 'days' uses a fairly complicated formula that determines the number of days since 1/1/1970. It's a simple matter from there to add 3 (because 1/1/1970 was a Thursday) and take the mod 7 of this figure to get the day of the week from the weekdays variable with substr.
If you're going to be working with dates a lot though, get XSLT2!
Related
I am trying to create an XSLT mapping to get the last(max) day of the previous month.
Eg- If I pass a value of 2019-10-17 to the mapping it should return
2019-09-30. The date format that I am using here is YYYY-MM-DD.
tried to get the month from the current data and subtract it with 1 so that it would return the previous month. But I am not able to get the max date of the last month.
xp20:month-from-dateTime (/ns0:ddSelecCorpoMasterOutputCollection/ns0:ddSelecCorpoMasterOutput/ns0:FROM_DATE_FILTER ) - 1
input- sysdate
o/p- maxdate of previous month
eg- i/p-2019-10-18
o/p- 2019-09-30
Thanks in advance.
Finding the last day of previous month in pure XSLT 1.0:
<xsl:template name="end-of-last-month">
<xsl:param name="date"/>
<!-- extract date components -->
<xsl:variable name="year" select="substring($date, 1, 4)"/>
<xsl:variable name="month" select="substring($date, 6, 2)"/>
<!-- go one month back -->
<xsl:variable name="y" select="$year - ($month = 1)"/>
<xsl:variable name="m" select="($month + 10) mod 12 + 1"/>
<!-- get month length -->
<xsl:variable name="cal" select="'312831303130313130313031'"/>
<xsl:variable name="leap" select="not($y mod 4) and $y mod 100 or not($y mod 400)"/>
<xsl:variable name="month-length" select="substring($cal, 2*($m - 1) + 1, 2) + ($m=2 and $leap)" />
<!-- output -->
<xsl:value-of select="$y" />
<xsl:value-of select="format-number($m, '-00')" />
<xsl:text>-</xsl:text>
<xsl:value-of select="$month-length" />
</xsl:template>
Example:
XML
<input>
<date>2019-01-15</date>
<date>2019-02-15</date>
<date>2019-03-15</date>
<date>2019-04-15</date>
<date>2019-05-15</date>
<date>2019-06-15</date>
<date>2019-07-15</date>
<date>2019-08-15</date>
<date>2019-09-15</date>
<date>2019-10-15</date>
<date>2019-11-15</date>
<date>2019-12-15</date>
<date>2020-01-15</date>
<date>2020-02-15</date>
<date>2020-03-15</date>
</input>
XSLT 1.0
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/input">
<output>
<xsl:for-each select="date">
<end-of-last-month date="{.}">
<xsl:call-template name="end-of-last-month">
<xsl:with-param name="date" select="."/>
</xsl:call-template>
</end-of-last-month>
</xsl:for-each>
</output>
</xsl:template>
<xsl:template name="end-of-last-month">
<xsl:param name="date"/>
<!-- extract date components -->
<xsl:variable name="year" select="substring($date, 1, 4)"/>
<xsl:variable name="month" select="substring($date, 6, 2)"/>
<!-- go one month back -->
<xsl:variable name="y" select="$year - ($month = 1)"/>
<xsl:variable name="m" select="($month + 10) mod 12 + 1"/>
<!-- get month length -->
<xsl:variable name="cal" select="'312831303130313130313031'"/>
<xsl:variable name="leap" select="not($y mod 4) and $y mod 100 or not($y mod 400)"/>
<xsl:variable name="month-length" select="substring($cal, 2*($m - 1) + 1, 2) + ($m=2 and $leap)" />
<!-- output -->
<xsl:value-of select="$y" />
<xsl:value-of select="format-number($m, '-00')" />
<xsl:text>-</xsl:text>
<xsl:value-of select="$month-length" />
</xsl:template>
</xsl:stylesheet>
Result
<?xml version="1.0" encoding="UTF-8"?>
<output>
<end-of-last-month date="2019-01-15">2018-12-31</end-of-last-month>
<end-of-last-month date="2019-02-15">2019-01-31</end-of-last-month>
<end-of-last-month date="2019-03-15">2019-02-28</end-of-last-month>
<end-of-last-month date="2019-04-15">2019-03-31</end-of-last-month>
<end-of-last-month date="2019-05-15">2019-04-30</end-of-last-month>
<end-of-last-month date="2019-06-15">2019-05-31</end-of-last-month>
<end-of-last-month date="2019-07-15">2019-06-30</end-of-last-month>
<end-of-last-month date="2019-08-15">2019-07-31</end-of-last-month>
<end-of-last-month date="2019-09-15">2019-08-31</end-of-last-month>
<end-of-last-month date="2019-10-15">2019-09-30</end-of-last-month>
<end-of-last-month date="2019-11-15">2019-10-31</end-of-last-month>
<end-of-last-month date="2019-12-15">2019-11-30</end-of-last-month>
<end-of-last-month date="2020-01-15">2019-12-31</end-of-last-month>
<end-of-last-month date="2020-02-15">2020-01-31</end-of-last-month>
<end-of-last-month date="2020-03-15">2020-02-29</end-of-last-month>
</output>
Demo: https://xsltfiddle.liberty-development.net/94AbWB5
If you have access to the XPath 2.0 date/time library,
(1) convert to an xs:date
<xsl:variable name="d" select="xs:date($in)"/>
(2) extract the day of the month:
<xsl:variable name="dom" select="day-from-date($d)"/>
(3) subtract this number of days from the date:
<xsl:variable name="result" select="$d - xs:dayTimeDuration('P1D') * $dom"/>
I'm working with a system that will only output the server time in Central Time Zone (CT). I need to convert this in XSLT to US Eastern Time.
Is there a built in method to translate this or do I need to use Regex?
<node time="02:14 pm CT" />
Current Output: 02:14 pm CT
Desired Output: 03:14 pm ET
There are at least two main paths to choose between, converting it into a time and using a time based library, or taking it as a string and doing straight string manipulation. The following is string manipulation:
<xsl:variable name="time" select="'11:14 pm CT'"/> <!-- the input value -->
<xsl:variable name="hours" select="number(substring-before($time,':'))"/> <!-- numeric hours -->
<xsl:variable name="mer" select="substring($time,7,2)"/> <!-- the am or pm part -->
<xsl:choose>
<xsl:when test="$hours < 12"> <!-- if we are 01-11 -->
<xsl:value-of select="substring(concat('0', $hours + 1), string-length(concat('0', $hours + 1)) - 1, 2)"/> <!-- add an hour and repad the string with leading zero, messy -->
</xsl:when>
<xsl:otherwise>
<xsl:text>01</xsl:text> <!-- we were 12, so just use 01 -->
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="substring($time, 3,4)"/> <!-- pull the minutes forward -->
<xsl:choose>
<xsl:when test="not($hours = 11)"> <!-- if we were not 11 for hours we keep the same am/pm -->
<xsl:value-of select="$mer"/>
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="$mer = 'pm'"> <!-- otherwise we flip it -->
<xsl:text>am</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>pm</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>
<xsl:text> ET</xsl:text>
There is no built-in method for this in XSLT 1.0. Regardless, it would have been fairly trivial to do - except for the fact that your time input is in 12-hour format. This makes the process rather tedious, so I have split it off to a processing template:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<node>
<xsl:attribute name="time">
<xsl:call-template name="time-offset">
<xsl:with-param name="time" select="node/#time"/>
</xsl:call-template>
</xsl:attribute>
</node>
</xsl:template>
<xsl:template name="time-offset">
<xsl:param name="time"/>
<xsl:param name="offset" select="1"/>
<xsl:param name="h12" select="substring($time, 1, 2)"/>
<xsl:param name="pm" select="contains($time,'p') or contains($time,'P')"/>
<xsl:param name="h24" select="$h12 mod 12 + 12*$pm"/>
<xsl:param name="newH24" select="($h24 + $offset + 24) mod 24"/>
<xsl:param name="newH12" select="($newH24 + 11) mod 12 + 1"/>
<xsl:param name="am.pm" select="substring('AMPM', 1 + 2*($newH24 > 11), 2)"/>
<xsl:value-of select="concat(format-number($newH12, '00'), substring($time, 3, 4), $am.pm, ' ET')"/>
</xsl:template>
</xsl:stylesheet>
When the above stylesheet is applied to the example input:
<node time="12:14 am CT" />
the result is:
<?xml version="1.0" encoding="UTF-8"?>
<node time="01:14 AM ET"/>
I have a space-separated list of coordinate tuples, with arbitrarily many tuples. Each tuple consists of a space-separated list of 2-dimensional coordinates. E.g. "1.1 2.8 1.2 2.9" represents a line from POINT(1.1 2.8) to POINT(1.2 2.9). I need this to instead be "1.1,2.8 1.2,2.9". How would I use XSLT to perform the replacement of space-to-comma between pairs of numbers? I have the "string(gml:LinearRing/gml:posList)".
This is being used on a Java Web Service that spits out GML 3.1.1 features with geometries. The service supports optional KML output, by using XSLT to transform the GML document into a KML document (at least, the chunks deemed "important"). I am locked into XSLT 1.0, so regex from XSLT 2.0 is not an option.
I am aware that GML uses lat/lon while KML uses lon/lat. That's being handled before XSLT, though it would be nice to have that also done with XSLT.
Thank you for your solution, Dimitre. I modified it a little to fit my needs, so I'll include that here in case it helps anyone else. It performs recursion through the coordinate list, assuming 2-dimensional tuples.
This performs two functions: axis swapping (lat/lon for lon/lat, per GML and KML specs) and changing the coordinate separator within each tuple from space ' ' to comma ','.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:gml="http://www.opengis.net/gml" exclude-result-prefixes="gml">
<xsl:output method="xml" encoding="UTF-8" indent="yes" />
<!-- other portions omitted -->
<xsl:template match="gml:pos">
<xsl:call-template name="coordinateSequence">
<xsl:with-param name="coords" select="normalize-space(string(.))" />
</xsl:call-template>
</xsl:template>
<xsl:template match="gml:posList">
<xsl:call-template name="coordinateSequence">
<xsl:with-param name="coords" select="normalize-space(string(.))" />
</xsl:call-template>
</xsl:template>
<xsl:template name="coordinateSequence">
<xsl:param name="coords" />
<xsl:if test="string-length($coords) > 0">
<xsl:variable name="lat" select="substring-before($coords, ' ')" />
<xsl:variable name="lon">
<xsl:value-of select="substring-before(substring-after($coords, ' '), ' ')" />
<xsl:if test="string-length(substring-before(substring-after($coords, ' '), ' ')) = 0">
<xsl:value-of select="substring-after($coords, ' ')" />
</xsl:if>
</xsl:variable>
<xsl:variable name="remainder" select="substring-after(substring-after($coords, ' '), ' ')" />
<xsl:value-of select="concat($lon, ',', $lat)" />
<xsl:if test="string-length($remainder) > 0">
<xsl:value-of select="' '" />
<xsl:call-template name="coordinateSequence">
<xsl:with-param name="coords" select="$remainder" />
</xsl:call-template>
</xsl:if>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
This transformation (also shows the intermediary steps):
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/*">
<xsl:variable name="vNorm" select="normalize-space()"/>
<xsl:variable name="vP1" select=
"concat(substring-before(., ' '), ',',
substring-before(substring-after($vNorm, ' '),' ')
)"/>
<xsl:variable name="vPart2" select="substring-after(substring-after($vNorm,' '),' ')"/>
<xsl:variable name="vP2" select=
"concat(substring-before($vPart2, ' '), ',',
substring-after($vPart2, ' ')
)"/>
<xsl:value-of select="$vP1"/>
==========
<xsl:value-of select="$vP2"/>
==========
<xsl:value-of select="concat($vP1, ' ', $vP2)"/>
</xsl:template>
</xsl:stylesheet>
when applied on this XML document:
<t>1.1 2.8 1.2 2.9</t>
produces the wanted, correct result (the last line):
1.1,2.8
==========
1.2,2.9
==========
1.1,2.8 1.2,2.9
For convenience, this code can be placed in to a named template to be called for each wanted Line:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/*">
<xsl:call-template name="convertLine"/>
</xsl:template>
<xsl:template name="convertLine">
<xsl:param name="pStr" select="."/>
<xsl:variable name="vNorm" select="normalize-space($pStr)"/>
<xsl:variable name="vP1" select=
"concat(substring-before($pStr, ' '), ',',
substring-before(substring-after($vNorm, ' '),' ')
)"/>
<xsl:variable name="vPart2" select="substring-after(substring-after($vNorm,' '),' ')"/>
<xsl:variable name="vP2" select=
"concat(substring-before($vPart2, ' '), ',',
substring-after($vPart2, ' ')
)"/>
<xsl:value-of select="concat($vP1, ' ', $vP2)"/>
</xsl:template>
</xsl:stylesheet>
<xsl:for-each select="tokenize($in, ' ')">
<xsl:value-of select="concat($t, if (position() mod 2) = 0 then ' ' else ',')"/>
</xsl:for-each>
I have a value like integer="1,2,3,4,5" in the xml. How can I count the total number using XSLT. So that the output gives me a count of 5
Regards,
Sam
Here's one way (there may be others). Simply translate all commas into empty strings, and then compare in difference in length of strings:
<xsl:value-of
select="string-length(#integer)
- string-length(translate(#integer, ',', '')) + 1" />
If you need to handle empty strings, try this instead
<xsl:value-of
select="string-length(#integer)
- string-length(translate(#integer, ',', ''))
+ 1 * (string-length(#integer) != 0)" />
If you want to count the comma-separated-values, but ALSO be able to reference the individual items, you can use a recursive template like such.
This XSLT 1.0 style-sheet will convert the comma-separated-values into nodes and then count them ...
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="as-nodes">
<xsl:call-template name="parse-comma-separated-values">
<xsl:with-param name="csv" select="t/#csv" />
</xsl:call-template>
</xsl:variable>
<xsl:value-of select="count(msxsl:node-set($as-nodes)/*)" />
</xsl:template>
<xsl:template name="parse-comma-separated-values">
<xsl:param name="csv" />
<xsl:choose>
<xsl:when test="$csv = ''"/>
<xsl:when test="not( contains( $csv, ','))">
<value-node value="{$csv}" />
</xsl:when>
<xsl:otherwise>
<value-node value="{substring-before($csv,',')}" />
<xsl:call-template name="parse-comma-separated-values">
<xsl:with-param name="csv" select="substring-after($csv,',')"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
... when applied to this input document ...
<t csv="1,2,3,4,5"/>
... produces ...
5
having a string length about of 120
here below my message string:
CID_Ultimate_Ben_Details=pabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumar
Ex: the message length of 140
output required as :
1 to 35 chars in first line
36 t0 70 chars in second line
71 to 105 chars in third line
106 to 140 in fourth line
here my xslt logic:
<xsl:if test ="./CID_Ultimate_Ben_Details != '' " >
<xsl:if test ="string-length(./CID_Ultimate_Ben_Details) != '11' and string-length(./CID_Ultimate_Ben_Details) != '8' ">
<xsl:if test="string-length(./CID_Ultimate_Ben_Details) > 1">
<xsl:value-of select="concat(':58D:',substring(./CID_Ultimate_Ben_Details,1,35))" />
</xsl:if>
<xsl:if test="string-length(./CID_Ultimate_Ben_Details) > 35">
<xsl:value-of select="concat('
',substring(./CID_Ultimate_Ben_Details,36,70))" />
</xsl:if>
<xsl:if test="string-length(./CID_Ultimate_Ben_Details) > 70">
<xsl:value-of select="concat('
',substring(./CID_Ultimate_Ben_Details,71,105))" />
</xsl:if>
<xsl:if test="string-length(./CID_Ultimate_Ben_Details) > 105">
<xsl:value-of select="concat('
',substring(./CID_Ultimate_Ben_Details,106,140))" />
</xsl:if>
</xsl:if>
<xsl:text>
</xsl:text >
</xsl:if>
output required as :
:58D:pabbisettishanmukhpraveenkumarpabbi
settishanmukhpraveenkumarpabbisetti
shanmukhpraveenkumarpabbisettishanm
ukhpraveenkumar
but now for the above logic output is coming as such:
:58D:pabbisettishanmukhpraveenkumarpabbi
settishanmukhpraveenkumarpabbisettishanmukhpraveenkumarpabbisettishanm
shanmukhpraveenkumarpabbisettishanmukhpraveenkumar
ukhpraveenkumar
why it was generating clrf in a irrespective manner.can any one suggest me please to achive my required output
Here is a correct and general (working for any text-length and number of output lines) XSLT 1.0 solution (the XSLT 2.0 solution is really elementary):
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:strip-space elements="*"/>
<xsl:param name="pmsgLength" select="140"/>
<xsl:param name="pnumLines" select="4"/>
<xsl:variable name="vmaxLineLength" select=
"ceiling($pmsgLength div $pnumLines)"/>
<xsl:template match="/*/text()" name="split">
<xsl:param name="pText" select="."/>
<xsl:param name="pnextLines" select="$pnumLines"/>
<xsl:param name="pHead" select="':58D:'"/>
<xsl:if test="$pnextLines">
<xsl:value-of select=
"concat('
',$pHead, substring($pText, 1, $vmaxLineLength))"/>
<xsl:call-template name="split">
<xsl:with-param name="pText" select="substring($pText, $vmaxLineLength+1)"/>
<xsl:with-param name="pnextLines" select="$pnextLines -1"/>
<xsl:with-param name="pHead" select="''"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
When this transformation is applied on the following XML document:
<t>pabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumarpabbisettishanmukhpraveenkumar</t>
the wanted, correct output is produced:
:58D:pabbisettishanmukhpraveenkumarpabbi
settishanmukhpraveenkumarpabbisetti
shanmukhpraveenkumarpabbisettishanm
ukhpraveenkumar
The third argument of substring() is the length required, not the end position as in Java.