Thank you verymuch Mr.Martin Honnen .
I was actually out of station and very sorry for the late response.
Your solution is absolutely fine.
Thanks a lot.
--- On Sat, 4/18/09, Martin Honnen <Martin(_dot_)Honnen(_at_)gmx(_dot_)de>
wrote:
From: Martin Honnen <Martin(_dot_)Honnen(_at_)gmx(_dot_)de>
Subject: Re: [xsl] Solution Needed for DB output
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Date: Saturday, April 18, 2009, 11:35 PM
balaganesh mohan wrote:
I am very new to xslt and i know basics of xslt only.
I tried to achieve the above output via key() function
as explained in your Mueneuch -2 ( grouping - thread)method.
But i get the same output as the db output.
I use jdeveloper as designing tool and oracle soa
suite 10.1.3.1.0 as server and xslt version 1.0 ( i dont
know whether xslt 2.0 is supported in soa server)
Assuming the XML input is
<getMatrixOutputCllection>
<outputVar>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>1</sublevel>
<status>approve</status>
</outputVar>
<outputVar>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>1</sublevel>
<status>reject</status>
</outputVar>
<outputVar>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>2</sublevel>
<status>pending</status>
</outputVar>
<outputVar>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>3</sublevel>
<status>yes</status>
</outputVar>
<outputVar>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>3</sublevel>
<status>no</status>
</outputVar>
<outputVar>
<level_id>2</level_id>
<assignee>jstein</assignee>
<reg>6000</reg>
<gold>4000</gold>
<sublevel>1</sublevel>
<status>go</status>
</outputVar>
<outputVar>
<level_id>2</level_id>
<assignee>jstein</assignee>
<reg>6000</reg>
<gold>4000</gold>
<sublevel>2</sublevel>
<status>proceed</status>
</outputVar>
<outputVar>
<level_id>2</level_id>
<assignee>jstein</assignee>
<reg>6000</reg>
<gold>4000</gold>
<sublevel>2</sublevel>
<status>pending</status>
</outputVar>
</getMatrixOutputCllection>
then this XSLT stylesheet
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml"
indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="lv"
match="outputVar" use="level_id"/>
<xsl:key name="sl"
match="sublevel"
use="concat(parent::outputVar/level_id, '|',
.)"/>
<xsl:template match="/*">
<xsl:copy>
<xsl:apply-templates
select="outputVar[generate-id() =
generate-id(key('lv', level_id)[1])]"/>
</xsl:copy>
</xsl:template>
<xsl:template match="outputVar">
<xsl:copy-of select="level_id | assignee | reg
| gold"/>
<xsl:apply-templates select="key('lv',
level_id)/sublevel[generate-id() =
generate-id(key('sl',
concat(parent::outputVar/level_id, '|',
.))[1])]"/>
</xsl:template>
<xsl:template match="sublevel">
<xsl:copy-of select="."/>
<xsl:copy-of select="key('sl',
concat(parent::outputVar/level_id, '|',
.))/following-sibling::status[1]"/>
</xsl:template>
</xsl:stylesheet>
creates the following output:
<getMatrixOutputCllection>
<level_id>1</level_id>
<assignee>jcooper</assignee>
<reg>1000</reg>
<gold>2000</gold>
<sublevel>1</sublevel>
<status>approve</status>
<status>reject</status>
<sublevel>2</sublevel>
<status>pending</status>
<sublevel>3</sublevel>
<status>yes</status>
<status>no</status>
<level_id>2</level_id>
<assignee>jstein</assignee>
<reg>6000</reg>
<gold>4000</gold>
<sublevel>1</sublevel>
<status>go</status>
<sublevel>2</sublevel>
<status>proceed</status>
<status>pending</status>
</getMatrixOutputCllection>
--
Martin Honnen
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
XSL-List info and archive:
http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to:
http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--