[xsl] Formatting Performance?

Subject: [xsl] Formatting Performance?
From: Jonathan Calvert <jonathan_calvert@xxxxxxxxx>
Date: Tue, 10 Apr 2001 05:36:45 -0700 (PDT)
I am looking to fine tune my XSL.  I am running into
performance issues with very large source files (2+
meg XML).  I am pretty sure performance is a parser
issue (I am using Java Xalan), but I would like to
optimize my XSL.

I have read indicates that SAX should be faster than
DOM across large documents, but I have found SAX to be
extremely slow (compared to DOM) once the source files
start approaching the 1 meg point.  Typical files that
I am processing are in the 5-10 meg range.

I am processing a series of XML based records and
transforming them into fixed length text.  Each
numeric field has to be a fixed length with leading
zeros if necessary.  Each alpha must be a fixed length
with trailing spaces if necessary.

I created two templates to do the formatting.  The
variable $whitespace is a variable with 100 spaces. 
The variable $numericfiller is a variable with 25 0s.

Is there a better way to go about this type of

I have also noticed that the xsl:number is extremely
expensive across numerous records (say 5K or more). 
Is this typical?

Finally, this is my second post.  Several people
helped me with my first problem and for that I am
greatly thankful.  I wrote several reply messages, but
for some reason the post never showed up on the list.

Thank you for your time.

<xsl:template name="FormatStringTest">
  <xsl:param name="PreFormatString"/>
  <xsl:param name="MaxSize"/>

  <xsl:value-of select="substring($PreFormatString, 1,
    <xsl:when test="$MaxSize >
      <xsl:value-of select="substring($whitespace, 1,
$MaxSize - string-length($PreFormatString))"/>

<xsl:template name="FormatNumberTest">
  <xsl:param name="PreFormatNumber"/>
  <xsl:param name="Size"/>

  <xsl:variable name="ResultNumber">
      <xsl:when test="string(number($PreFormatNumber))
= 'NaN'">
select="substring($numericfiller, 1, $Size)"/>
select="substring($numericfiller, 1, $Size -
string-length($PreFormatNumber) - $Size + 1, $Size)"/>
<xsl:value-of select="$ResultNumber"/>

Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread