[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: foreign keys in a xml-database

Subject: Re: foreign keys in a xml-database
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Tue, 07 May 2002 22:04:24 +0200
database templetes
ChivaBaba@xxxxxxx wrote:
The Stylesheet I use, transforms the first.xml into html-files.
> The problem I got in my xsl-file now,is that I need to output
> for each project the included tools sorted first by category
> and second by name.

You could setup a two pass processing (preferred), firts
pass merginig, second pass sorting, or refer to the data
directly. The latter is likely expensive.

The first difficuilty is, that I want only those release-nodes
> (childs of tools from second.xml) to be copied, whose name fits
> the version-attribute of the current tool-node in first.xml.

You probably need a composite key.

  <xsl:key name="tool-version" match="tool"
     use="concat(@name,'#',release/@name)"/>
  <!-- convenience variable holding second.xml -->
  <xsl:variable name="tool-def" select="document('second.xml')"/>

  <xsl:template match="project">
    ...
    <xsl:for-each select="tool">
      <!-- build the key of the tool used -->
      <xsl:variable name="key" select="concat(@name,'#',@version)"/>
      <!-- change context for key lookup -->
      <xsl:for-each select="$tool-def">
        <xsl:apply-templates select="key('tool-version',$key)"/>
      </xsl:for-each>
      ...
    </xsl:for-each>
   </xsl:template>

Define appropriate templetes to copy the stuff you need from
the tool detail definition data.

Building the two pass approach can be done using an
intermediate file if you are using the XSLT processor from
the command line, or using the first pass transformer as
SAXFilter and pipe the result to the second. This requires
two style sheets, of course, one for merging and the second
for sorting.
In order to have one style sheet only you can store the result
of the merge in a variable and use exsl:node-set() to convert
it into a sortable node set:

  <xsl:template match="project">
    <xsl:variable name="merge-result">
      <xsl:for-each select="tool">
       ...
    </xsl:variable>
    <xsl:for-each select="exxl:node-set($merge-result)">
      <xsl:sort select="@category">
      <xsl:sort select="@name">
       ... produce your HTML here...
    </xsl:for-each>

J.Pietschmann



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.