Velocity Reviews

Velocity Reviews (
-   XML (
-   -   dynamically generated keys in xslt? (

alex 05-17-2004 10:00 PM

dynamically generated keys in xslt?
I'm new to xslt, and I am attempting to use it to produce a
comma-separated-value file from a large, dynamically-generated data
file formatted in xml (examples of the xml file and my xslt style
sheet follow). It works pretty well, but xsltproc takes an extremely
long time to process the data file when it grows fairly large (>1MB).
I've read that using keys can improve processing time on large
documents, however I don't know the number of key tables required or
which nodes should be placed in the key table until the document must
be processed. I realize that I can use a second "preprocessor" xslt
style sheet to dynamically create the appropriate keys within my own
style sheet, but this approach seems cumbersome and I would prefer to
create the keys dynamically within a single sheet.

Is this possible in xslt, or is this application beyond the scope of
what xslt is designed to do?

Any help greatly appreciated!

- Alex


The data file is formatted as follows:

<system version="1.0">
<binned_data type="step">
<value ts="0">3.045139</value>
<value ts="1">3.048611</value>
<value ts="2">3.052083</value>...

I'm using the following xslt style sheet to produce the csv output

<xsl:stylesheet xmlns:xsl=""
<xsl:output method="text"/>
<xsl:variable name="newline">

<xsl:template match="/">
<!-- Template for CSV values -->
select="self::node()/descendant::binned_data[@type='step'][1]" />
<xsl:template match="binned_data">
<xsl:for-each select="value">
<xsl:variable name ="i" select="position()" />
<xsl:for-each select="//binned_data[@type='step']">
<xsl:value-of select="value[$i]"/><xsl:text>,
<xsl:value-of select="$newline"/>

<!-- suppress everything else -->
<xsl:template match="*"></xsl:template>


All times are GMT. The time now is 06:46 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.