[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Grouping / Count Issue


Subject: RE: [xsl] Grouping / Count Issue
From: "Gabriel Osorio" <gosorio@xxxxxxxxxxx>
Date: Mon, 28 Nov 2005 11:02:07 -0500

Maybe with:

<!-- F Fields -->
<xsl:apply-templates select="Field[@dataType = 'F']" />
<!-- other -->
<xsl:apply-templates select="Field[not(@dataType = 'F')]" />



-----Original Message-----
From: Miraodb [mailto:miraodb@xxxxxxxxxxx] 
Sent: Monday, November 28, 2005 10:39 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: [xsl] Grouping / Count Issue

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
Keywords
xsl