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

Re: Converting a SQL XML Resultset using XSL...

Subject: Re: Converting a SQL XML Resultset using XSL...
From: "Joerg Heinicke" <joerg.heinicke@xxxxxx>
Date: Thu, 28 Feb 2002 20:53:09 +0100
transform xml resultset
Hello Aaron,

if you don't want the SQL-solution or can not use it, here is the
XSLT-solution:

Your problem is a grouping problem. Some information you can find here:
http://www.jenitennison.com/xslt/grouping/index.xml. In your case you need a
multiple level grouping, first by id, second by tag_name. Using the
Muenchian Method you need for this at first the id and at second a
concatenated string with id and tag_name:

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="ISO-8859-1" indent="yes"/>

<xsl:key name="rows1" match="row" use="id"/>
<xsl:key name="rows2" match="row" use="concat(id,'::',tag_name)"/>

<xsl:template match="page">
    <xsl:copy>
        <xsl:apply-templates select="rowset/row[count( . | key('rows1',
id)[1] ) = 1]" mode="rows1"/>
    </xsl:copy>
</xsl:template>

<xsl:template match="row" mode="rows1">
    <individual id="{id}" name="{display_name}">
        <xsl:apply-templates select="key('rows1',id)[count( . | key('rows2',
concat(id,'::',tag_name))[1] ) = 1]" mode="rows2"/>
    </individual>
</xsl:template>

<xsl:template match="row" mode="rows2">
    <tag name="{tag_name}">
        <xsl:apply-templates select="key('rows2',
concat(id,'::',tag_name))"/>
    </tag>
</xsl:template>

<xsl:template match="row">
    <tmp name="{tmp_name}" score="{score}"/>
</xsl:template>

</xsl:stylesheet>

Hope this helps. But maybe it's better to use the SQL-solution provided by
Kirk.

Regards,

Joerg


 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.