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

Grouping / Count Issue

Subject: Grouping / Count Issue
From: "Miraodb" <miraodb@xxxxxxxxxxx>
Date: Mon, 28 Nov 2005 16:38:46 +0100
xml record count
Hi all,

i'm facing the current issue, i have this xml:

<Report type="Tabular" name="SE9001_TabularReport"
description="SE9001_TabularReport" asOfDate="2005-11-04 00:00:00"
generatedDate="2005-11-27 17:02:58">
  <Layout>
    <Field name="report_code" title="report_code" dataType="V"
width="auto"/>
    <Field name="country_code" title="Country Code" dataType="V"
width="auto"/>
    <Field name="report_sect" title="report_sect" dataType="V"
width="auto"/>
    <Field name="reportrow" title="ReportRow" dataType="V" width="auto"/>
    <Field name="centralbank" title="02CentralBank" dataType="F"
width="auto"/>
    <Field name="creditinstitutions" title="03CreditInstitutions"
dataType="F" width="auto"/>
    <Field name="othermfis" title="04OtherMFIs" dataType="F" width="auto"/>
    <Field name="centralgovt" title="06CentralGovt" dataType="F"
width="auto"/>
    <Field name="regionalgovt" title="08RegionalGovt" dataType="F"
width="auto"/>
    <Field name="localgovt" title="09LocalGovt" dataType="F" width="auto"/>
    <Field name="socialsecurity" title="10SocialSecurity" dataType="F"
width="auto"/>
    <Field name="insurance_pension" title="12Insurance_Pension" dataType="F"
width="auto"/>
    <Field name="otherfinancial" title="13OtherFinancial" dataType="F"
width="auto"/>
    <Field name="privatecorp" title="14PrivateCorp" dataType="F"
width="auto"/>
    <Field name="publiccorp" title="15PublicCorp" dataType="F"
width="auto"/>
    <Field name="households" title="16Households" dataType="F"
width="auto"/>
    <Field name="interco" title="60InterCo" dataType="F" width="auto"/>
  </Layout>
  <GrandTotal>
    <SubTotalValues>
      <FieldValue fieldName="centralbank" fieldValue="259.69"
fieldValueIsNull="false" fieldValueNatural="259.690855"/>
      <FieldValue fieldName="creditinstitutions" fieldValue="75,394.60"
fieldValueIsNull="false" fieldValueNatural="75394.60450346"/>
      <FieldValue fieldName="othermfis" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="centralgovt" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="regionalgovt" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="localgovt" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="socialsecurity" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="insurance_pension" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="otherfinancial" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="privatecorp" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="publiccorp" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="households" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
      <FieldValue fieldName="interco" fieldValue="0.00"
fieldValueIsNull="false" fieldValueNatural="0.0"/>
    </SubTotalValues>
    <RecordValues>
      <Record>
        <FieldValue fieldName="report_code" fieldValue="100"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="country_code" fieldValue="US"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="report_sect" fieldValue="01"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="reportrow" fieldValue="004230"
fieldValueIsNull="false" fieldValueNatural="05003"/>
        <FieldValue fieldName="creditinstitutions" fieldValue="3304"
fieldValueIsNull="false" fieldValueNatural="200.933275"/>
        <FieldValue fieldName="otherfinancial" fieldValue="332"
fieldValueIsNull="false" fieldValueNatural="200.933275"/>
      </Record>
      <Record>
        <FieldValue fieldName="report_code" fieldValue="101"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="country_code" fieldValue="UK"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="report_sect" fieldValue="02"
fieldValueIsNull="true" fieldValueNatural=""/>
        <FieldValue fieldName="reportrow" fieldValue="004230"
fieldValueIsNull="false" fieldValueNatural="05003"/>
        <FieldValue fieldName="creditinstitutions" fieldValue="4458"
fieldValueIsNull="false" fieldValueNatural="200.933275"/>
        <FieldValue fieldName="otherfinancial" fieldValue="556"
fieldValueIsNull="false" fieldValueNatural="200.933275"/>
      </Record>
    </RecordValues>
  </GrandTotal>
</Report>

And up to now i managed to get the follwing result:

100US0100423003 330413 332

101UK0200423003 445813 556

but what i want is:

100US0100423003 3304

100US0100423013 332

101UK0200423003 4458

101UK0200423013 556

So basically i need to split for each record the fieldValues that have a
dataType='F'

Obviously i can have an infinite number of records and fieldValues (for both
V or F datatype).



I'm sure i can do that with recursion or grouping.

My current XSL is :



<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">

<xsl:for-each select="Report/GrandTotal/RecordValues/Record">

<xsl:for-each select="FieldValue">

<xsl:variable name="currFieldName" select="@fieldName"/>

<xsl:if test="/Report/Layout/Field[@name=$currFieldName]/@dataType='V'">

<xsl:value-of select="@fieldValue" />

</xsl:if>

<xsl:if test="/Report/Layout/Field[@name=$currFieldName]/@dataType='F'">

<xsl:value-of
select="substring(/Report/Layout/Field[@name=$currFieldName]/@title,1,2)" />

<xsl:text>&#160;</xsl:text>

<xsl:value-of select="@fieldValue" />

</xsl:if>

</xsl:for-each>

<xsl:text>

</xsl:text>

</xsl:for-each>

</xsl:template>

</xsl:stylesheet>

Thanks a lot in advance

fabrice

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.