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

Grouping

Subject: Grouping
From: Paul A Kloepper <kloepper@xxxxxxxxx>
Date: Thu, 22 Mar 2007 01:02:46 -0700 (PDT)
 Grouping
I've got the following (shortened) xml that I'm trying to group in a particular way so that I can graph the numbers as series.

<?xml version="1.0" encoding="us-ascii"?>
<xbrl xmlns="http://www.xbrl.org/2003/instance" xmlns:link="http://www.xbrl.org/2003/linkbase" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:bne2="http://www.bowne.com/xbrl2" xmlns:bne="http://www.bowne.com/xbrl" xmlns:iso4217="http://www.xbrl.org/2003/iso4217" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:usfr-pte="http://www.xbrl.org/us/fr/common/pte/2005-02-28">
<link:schemaRef xlink:type="simple" xlink:href="z bne-schemas/bne-20060930.xsd"/>
<link:schemaRef xlink:type="simple" xlink:href="z bne-schemas/bne-ssu_xbrl.xsd"/>

<!--Element Section-->

<usfr-pte:AccountsPayable contextRef="BalanceAsOf_31Dec2005_Unaudited" unitRef="USD" decimals="INF">31089000</usfr-pte:AccountsPayable>
<usfr-pte:AccountsPayable contextRef="BalanceAsOf_30Sep2006_Unaudited" unitRef="USD" decimals="INF">34896000</usfr-pte:AccountsPayable>
<usfr-pte:AccountsReceivableTradeGross contextRef="BalanceAsOf_31Dec2005_Unaudited" unitRef="USD" decimals="INF">129002000</usfr-pte:AccountsReceivableTradeGross>
<usfr-pte:AccountsReceivableTradeGross contextRef="BalanceAsOf_30Sep2006_Unaudited" unitRef="USD" decimals="INF">157694000</usfr-pte:AccountsReceivableTradeGross>
<usfr-pte:AccountsReceivableTradeNet contextRef="BalanceAsOf_31Dec2005_Unaudited" unitRef="USD" decimals="INF">120450000</usfr-pte:AccountsReceivableTradeNet>
<usfr-pte:AccountsReceivableTradeNet contextRef="BalanceAsOf_30Sep2006_Unaudited" unitRef="USD" decimals="INF">147759000</usfr-pte:AccountsReceivableTradeNet>
<usfr-pte:AccumulatedComprehensiveIncome contextRef="BalanceAsOf_31Dec2005_Unaudited" unitRef="USD" decimals="INF">-2475000</usfr-pte:AccumulatedComprehensiveIncome>
<usfr-pte:AccumulatedComprehensiveIncome contextRef="BalanceAsOf_30Sep2006_Unaudited" unitRef="USD" decimals="INF">-976000</usfr-pte:AccumulatedComprehensiveIncome>

</xbrl>


The desired output will look like this (so that it can be graphed as multiple series, ie., Assets is one series, Liabilities, another series.):

<?xml version="1.0" encoding="UTF-8"?>
<Company name="ABC" symbol="A" >
<!-- These need to be grouped by period -->
<Datapoint>
<datePeriod>BalanceAsOf_31Dec2005_Unaudited</datePeriod>
<Assets>563248000</Assets>
<Liabilities>251475000</Liabilities>
</Datapoint>
<Datapoint>
<datePeriod>BalanceAsOf_30Sep2006_Unaudited</datePeriod>
<Assets>517550000</Assets>
<Liabilities>252937000</Liabilities>
</Datapoint>
</Company>


 
My current XSLT looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xbrli="http://www.xbrl.org/2003/instance" xmlns:usfr-pte="http://www.xbrl.org/us/fr/common/pte/2005-02-28">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:attribute-set name="nameSymbol">
<xsl:attribute name="name">ABC</xsl:attribute>
<xsl:attribute name="symbol">A</xsl:attribute>
</xsl:attribute-set>
<xsl:variable name="XML" select="/"/>
<xsl:template match="/">
<!--Get Company Element -->
<xsl:element name="Company" use-attribute-sets="nameSymbol">
<xsl:for-each select="xbrli:xbrl">
<!-- Make Each Element The Context Node --> 
<!--xsl:for-each select="usfr-pte:*"-->
<!-- Make the Group Elements from all the 'contextRef' attributes -->
<xsl:for-each-group select="usfr-pte:*" group-by="@contextRef">
<!-- Actually return each grouping key here (a value from the 'current-group()' hash table -->
<xsl:value-of select="current-grouping-key()"/>
<!-- Create each group ('current-group()' is the hash table?) -->
<xsl:for-each select="current-group()">
<!-- Inside each group, create these elements -->
<xsl:element name="Datapoint">
<!-- Get attribute value as an Element -->
<xsl:element name="datePeriod">
<xsl:value-of select="@contextRef"/>
</xsl:element>
<!-- Get node local-name as name and (text) value as the Element value -->
<xsl:element name="{local-name()}">
<xsl:value-of select="string(.)"/>
</xsl:element>
</xsl:element>
</xsl:for-each>
</xsl:for-each-group>
<!--/xsl:for-each-->
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>


and it returns this (which is not grouped properly):

<?xml version="1.0" encoding="UTF-8"?>
<Company name="ABC" symbol="A">BalanceAsOf_31Dec2005_Unaudited<Datapoint>
<datePeriod>BalanceAsOf_31Dec2005_Unaudited</datePeriod>
<AccountsPayable>31089000</AccountsPayable>
</Datapoint>
<Datapoint>
<datePeriod>BalanceAsOf_31Dec2005_Unaudited</datePeriod>
<AccountsReceivableTradeGross>129002000</AccountsReceivableTradeGross>
</Datapoint>
<Datapoint>
<datePeriod>BalanceAsOf_31Dec2005_Unaudited</datePeriod>
<AccountsReceivableTradeNet>120450000</AccountsReceivableTradeNet>
</Datapoint>
<Datapoint>
<datePeriod>BalanceAsOf_31Dec2005_Unaudited</datePeriod>
<AccumulatedComprehensiveIncome>-2475000</AccumulatedComprehensiveIncome>
</Datapoint>
</Company>

Anyone have any ideas on how I can get the desired output?

Thank you,

Paul


 
____________________________________________________________________________________
Looking for earth-friendly autos? 
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

Current Thread
  • Grouping
    • Paul A Kloepper - 22 Mar 2007 08:03:09 -0000 <=

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.