[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Solution Needed for DB output
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.Honnen@xxxxxx> wrote: > From: Martin Honnen <Martin.Honnen@xxxxxx> > Subject: Re: Solution Needed for DB output > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > 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/
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|