This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: newbie - comparing attributes in nodes
- From: "G. Ken Holman" <gkholman at CraneSoftwrights dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Wed, 16 Jan 2002 13:44:49 -0500
- Subject: Re: [xsl] newbie - comparing attributes in nodes
- Reply-to: xsl-list at lists dot mulberrytech dot com
At 2002-01-16 16:50 +0000, Hesselberth, Jan wrote:
>I tried to follow the examples in the book and came up with variants as
>below but none work. Can someone please help?
>
><xsl:for-each select="/Report/printCategory">
> <xsl:if
>test="not(@ID=preceding::printCategory/@ID)">
> <fo:table-row>
> <fo:table-cell>
> <fo:block>Print Category
><xsl:value-of select="@ID"/></fo:block>
> </fo:table-cell>
> </fo:table-row>
> </xsl:if>
That code works for me using XT (see below) ... what are your results?
(note that since you are looking at siblings, using preceding-sibling::
will check for fewer nodes than using preceding::).
............... Ken
T:\ftemp>type jan.xml
<Report>
<printCategory ID="20"><TranName>FURTHER
ADVANCE</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="20"><TranName>INITIAL
DRAWDOWN</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="20"><TranName>RETENTION
RELEASE</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="21"><TranName>INTEREST
ADJUSTMENT</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="21"><TranName>INTEREST ADJUSTMENT
(CREDIT)</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="21"><TranName>INTEREST
CHARGED</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="21"><TranName>REDEMPTION INTEREST
CHARGED</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="22"><TranName>ARRANGEMENT
FEE</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
<printCategory ID="22"><TranName>FIXED RATE BOOKING
FEE</TranName><CRAmount>0</CRAmount><DRAmount>0</DRAmount></printCategory>
</Report>
T:\ftemp>type jan.xsl
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
version="1.0">
<xsl:output indent="yes"/>
<xsl:template match="/">
<fotable>
<xsl:for-each select="/Report/printCategory">
<xsl:if test="not(@ID=preceding::printCategory/@ID)">
<fo:table-row>
<fo:table-cell>
<fo:block>Print Category
<xsl:value-of select="@ID"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
<fo:table-row>
<fo:table-cell>
<fo:block>
<xsl:value-of select="TranName"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fotable>
</xsl:template>
</xsl:stylesheet>
T:\ftemp>xt jan.xml jan.xsl jan.fo
T:\ftemp>type jan.fo
<?xml version="1.0" encoding="utf-8"?>
<fotable xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:table-row>
<fo:table-cell>
<fo:block>Print Category
20</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>FURTHER
ADVANCE</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>INITIAL
DRAWDOWN</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>RETENTION
RELEASE</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>Print Category
21</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>INTEREST
ADJUSTMENT</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>INTEREST ADJUSTMENT
(CREDIT)</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>INTEREST
CHARGED</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>REDEMPTION INTEREST
CHARGED</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>Print Category
22</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>ARRANGEMENT
FEE</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block>FIXED RATE BOOKING
FEE</fo:block>
</fo:table-cell>
</fo:table-row>
</fotable>
--
Training Blitz: 3-days XSLT/XPath, 2-days XSLFO - Feb 18-22, 2002
- (Early-bird date for discounts is this Friday!)
G. Ken Holman mailto:gkholman@CraneSoftwrights.com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (Fax:-0995)
ISBN 0-13-065196-6 Definitive XSLT & XPath
ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath
ISBN 1-894049-07-1 Practical Formatting Using XSLFO
XSL/XML/DSSSL/SGML/OmniMark services, books(electronic, printed),
articles, training(instructor-live,Internet-live,web/CD,licensed)
Next public training: 2002-01-18,02-11,12,13,15,18,21,
- 03-11,14,15,18,19,04-08,09,10,12,06-04,07
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list