This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: numbering - counting - grouping
- To: <xsl-list at mulberrytech dot com>
- Subject: Re: numbering - counting - grouping
- From: Frédéric SCHWEBEL <schwebel at rfv dot insa-lyon dot fr>
- Date: Wed, 8 Nov 2000 17:07:07 +0100
- References: <51796B6D0747FE43B4F84E14AF3C4AA311AE57@gray.net.klopotek.de>
- Reply-To: xsl-list at mulberrytech dot com
Hi,
There's a difference between child elements and attributes. You have two
solutions :
Either you change your XML file with :
<contributor type="AU"> instead of <contributor><type>AU</type>
then type is an attribute of constructor and you can write
<xsl:apply-templates select="contributor [@type='AU']"> in your xsl sheet.
or if you want to keep your original xml file then write
<xsl:apply-templates select="contributor/type[.='AU']"> (but i'm not really
sur about the syntax here)
Does it help ?
Fred
----- Original Message -----
From: "Sellmer-Brüls, Barbara" <B.Sellmer-Bruels@klopotek.de>
To: <XSL-List@mulberrytech.com>
Sent: Wednesday, November 08, 2000 2:52 PM
Subject: numbering - counting - grouping
> Hi,
>
> I've got a problem with numbering (or counting ? or grouping?), and I
don't
> know how to solve it with a (for some reasons given) stylesheet structure.
> The XML is as follows:
> - contains different books
> - each book can have different contributors
> - each contributor has a type
>
> My stylesheet applies templates for <book>.
> Within <book> it applies templates to contributors depending on their
type.
> <xsl:apply-templates select="contributor [type='AU']">
> some sorting of all contributors = AU based on an element I have
not
> listed here
> </xsl:apply-templates>
> <xsl:apply-templates select="contributor [type='ED']">
> some sorting of all contributors = ED based on an element I have
not
> listed here
> </xsl:apply-templates>
>
> The contributor template states that
> - some output is generated only for the first occurance of a set of
> 'AUcontributors' or 'ED contributors', and
> - then that all names from the selected contributors nodes are to be
listed:
>
> <xsl:template match="contributor">
> <xsl:if test="position()='1'">
> <xsl:value-of select="type"/><xsl:text>:</xsl:text><br/>
> </xsl:if>
> <xsl:value-of select="name"/><br/>
> </xsl:template>
>
> What I need to add to the output a numbering of the contributors 'header'
> data, so that the output looks like:
> book 1
> 1. type is AU
> Anna
> 2. type is ED
> Ernst
> Elisabeth
>
> book2
> 1. type is AU
> Andrew
> 2. type is CON
> Cindy
>
> I tried it with variables and parameters but it does not work.
> Has anybody any Idea?
>
> This is the XML document:
>
> <?xml version="1.0" encoding="ISO-8859-1"?>
> <list>
> <book>
> <id>1</id>
> <contributor>
> <type>AU</type>
> <name>Anna</name>
> </contributor>
> <contributor>
> <type>ED</type>
> <name>Ernst</name>
> </contributor>
> <contributor>
> <type>ED</type>
> <name>Elisabeth</name>
> </contributor>
> </book>
> <book>
> <id>2</id>
> <contributor>
> <type>AU</type>
> <name>Andrew</name>
> </contributor>
> <contributor>
> <type>CON</type>
> <name>Cindy</name>
> </contributor>
> </book>
> </list>
>
> Sorry for this lengthy email - but thanks in advance!
> Barbara
> ---
> Barbara Sellmer-Bruels
> b.sellmer-bruels@klopotek.de
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list