dynamically generated keys in xslt?

A

alex

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">
<property_1>
<name>future</name>
<binned_data type="step">
<value ts="0">3.045139</value>
<value ts="1">3.048611</value>
<value ts="2">3.052083</value>...
</binned_data>
</property_1>
<property_2></property_2>...
<system>

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

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:eek:utput method="text"/>
<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>

<xsl:template match="/">
<!-- Template for CSV values -->
<xsl:apply-template
select="self::node()/descendant::binned_data[@type='step'][1]" />
</xsl:template>
<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:text>-->
</xsl:for-each>
<xsl:value-of select="$newline"/>
</xsl:for-each>-->
</xsl:template>

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

</xsl:stylesheet>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top