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

Re: Solution Needed for DB output

Subject: Re: Solution Needed for DB output
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Sat, 18 Apr 2009 20:05:21 +0200
Re:  Solution Needed for DB output
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/

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.