doekman / xml2json-xslt

Automatically exported from code.google.com/p/xml2json-xslt
BSD 3-Clause "New" or "Revised" License
38 stars 17 forks source link

The String escaping code is not efficient and leads to java.lang.StackOverflowError exception #23

Open afayes opened 6 years ago

afayes commented 6 years ago

When I used an XML files that was 1.2 MB, the escape-string template threw a java.lang.StackOverflowError exception because of all the recursive calls.

Rather than do something like

`

            </xsl:call-template>`

you can do something like:

`

    <xsl:variable name="string" select="replace($string, '&quot;',\&quot;')"/>         
    <xsl:variable name="string" select="replace($string, '&#09;', '\t')"/>
    <xsl:variable name="string" select="replace($string, '&#10;','\n')"/>
    <xsl:variable name="string" select="replace($string, '&#13;', '\r')"/>         
      <xsl:value-of select="$string"/>
</xsl:template>`