This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Formatting 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]