Skip navigation

India User Group

2 Posts authored by: prabhu deva
Share This:

HI Team,


  1. I have designed a simple XSLT to remove the extra empty lines and empty space  in a string. Please use the below during string transformation J


<xsl:stylesheet xmlns:xsl="" version="1.0">

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

  <xsl:template match="@*|node()">


      <xsl:apply-templates select="@*|node()" />



  <xsl:template match="value/text()" name="tokenize">

    <xsl:param name="text" select="." />

    <xsl:param name="separator" select="'&#xA;'" />


      <xsl:when test="not(contains($text, $separator))">

<xsl:value-of select="normalize-space($text)" />



<xsl:value-of select="normalize-space(substring-before($text, $separator))" />

        <xsl:if test="substring-before($text, $separator) != ''">

<xsl:value-of select=" $separator"/>


<xsl:call-template name="tokenize">

<xsl:with-param name="text" select="substring-after($text, $separator)" />






Share This:

Hi All,

I faced an error named Premature end of file in XSLT transformation of XML, which was caused by the following reason.

1. I forgot to add the start and end of Root element before For loop.

Following XSLT is for grouping the transactions which has same branch code.


in the following XSLT tag <body> was not present at first. once I add it the issue got resolved.






  <xsl:output indent="yes" />

  <xsl:template match="value">


      <xsl:for-each select="Transaction">

    <xsl:sort select="Branch_Code" />

        <xsl:variable name="b" select="Branch_Code"/>

        <xsl:if test="not(preceding-sibling::*[Branch_Code = $b])">



               <xsl:value-of select="Branch_Code"/>



  <xsl:value-of select="Email_Recipients"/>


           <xsl:for-each select="/value/Transaction[Branch_Code=$b]">

                <xsl:sort select="Branch_Code"/>



   <xsl:value-of select="Tran_No"/>



   <xsl:value-of select="Error_Description"/>











To Avoid the premature End of fie, every resulting XML must have a Root element

Filter Blog

By date:
By tag: