Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Newbie XSL Question: Comparing to preceding-sibling within for-each

From: Red <funkandlove@-----.--.-->
To: NULL
Date: 5/9/2007 4:48:00 AM

Hi,

Pretty new to XML, but I have adopted some reports through my job that
I need to work with.  I've got some training lined up next month, but
until then I have a few modifications to existing XSL files that I
need to make pretty sharpish.

We have certain reports that contain grouping and sums in the output.
The existing XSL just reads out all rows to html tables.  I would like
to make these easier to read by eliminating all duplicates within a
row.  At the moment, I dont have the access to change the XML output,
just the XSL.  I hope the following example explains it well enough.
Any questions, let me know.

Thanks,

Red.



== XML ===========================================

<?xml version="1.0"?>
 <rs:data>
  <z:row BRANCH='Birmingham' ACCOUNT_NO='1001001' STATUS='Open'
BALANCE='5380.04'/>
  <z:row BRANCH='Birmingham' ACCOUNT_NO='1001002' STATUS='Open'
BALANCE='1281.12'/>
  <z:row BRANCH='London' ACCOUNT_NO='1001003' STATUS='Closed'
BALANCE='1015.32'/>
  <z:row BRANCH='London' ACCOUNT_NO='1001004' STATUS='Open'
BALANCE='9866.53'/>
  <z:row BRANCH='London' ACCOUNT_NO='1001005' STATUS='Open'
BALANCE='1659.55'/>
  <z:row BRANCH='Glasgow' ACCOUNT_NO='1001006' STATUS='Open'
BALANCE='6944.21'/>
 </rs:data>



== Current XSL ====================================

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform">
 <xsl:template match="/">
  <table>
   <xsl:for-each select="//z:row">
    <tr>
     <td><xsl:value-of select="@BRANCH"/></td>
     <td><xsl:value-of select="@ACCOUNT_NO"/></td>
     <td><xsl:value-of select="@STATUS"/></td>
     <td><xsl:value-of select="@BALANCE"/></td>
    <tr>
   </xsl:for-each>
  </table>
 </xsl:template>
</xsl:stylesheet>
<!--end-->



== Current Output =================================

Birmingham  1001001  Open    5380.04
Birmingham  1001002  Open    1281.12
London      1001003  Closed  1015.32
London      1001004  Open    9866.53
London      1001005  Open    1659.55
Glasgow     1001006  Open    6944.21


== Required output ================================

Birmingham  1001001  Open    5380.04
            1001002  Open    1281.12
London      1001003  Closed  1015.32
            1001004  Open    9866.53
            1001005  Open    1659.55
Glasgow     1001006  Open    6944.21



transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent