dynamically generated keys in xslt?

Discussion in 'XML' started by alex, May 17, 2004.

  1. alex

    alex Guest

    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>
     
    alex, May 17, 2004
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sandeep Kanwal

    serial keys/validation keys

    sandeep Kanwal, Oct 29, 2004, in forum: C++
    Replies:
    1
    Views:
    598
    Mike Wahler
    Oct 29, 2004
  2. Harry George
    Replies:
    9
    Views:
    745
    sonal
    Jun 13, 2006
  3. Replies:
    10
    Views:
    756
    Daniel T.
    Feb 3, 2006
  4. alan
    Replies:
    3
    Views:
    381
    Victor Bazarov
    Nov 28, 2007
  5. A. Farber
    Replies:
    10
    Views:
    251
    A. Farber
    Jun 12, 2004
Loading...

Share This Page