[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Formatting Performance?

Subject: Formatting Performance?
From: Jonathan Calvert <jonathan_calvert@xxxxxxxxx>
Date: Tue, 10 Apr 2001 05:36:45 -0700 (PDT)
formatting for performance
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
formatting?

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,
$MaxSize)"/>
  <xsl:choose>
    <xsl:when test="$MaxSize >
string-length($PreFormatString)">
      <xsl:value-of select="substring($whitespace, 1,
$MaxSize - string-length($PreFormatString))"/>
    </xsl:when>
  </xsl:choose>
</xsl:template>

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

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

__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.