By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,023 Members | 1,235 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,023 IT Pros & Developers. It's quick & easy.

dynamically generated keys in xslt?

P: n/a
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>

Jul 20 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.