RE: [xsl] Use of xsl:number, ignoring some elements

Subject: RE: [xsl] Use of xsl:number, ignoring some elements
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 4 Aug 2004 09:04:40 +0100
> I want to make the xsl:number to "ignore" some elements while 
> counting, but
> I don't have the way to know which the elements are so I can't put any
> selection on the "count" attribute.

I'm afraid I'm having difficulty understanding the question. You must have
*some* way to know which elements you want to ignore!

> The main [Tamino query]
> I have is one that retrieves a HUGE XML document with a 
> section like this one:
> 
> <family>
>     <siblings>
>         <channelId>ch1</channelId>
>         <channelId>ch2</channelId>
>     </siblings>
>     <children>
>         <channelId>ch3</channelId>
>         <channelId>ch4</channelId>
>         <channelId>ch5</channelId>
>     </children>
> </family>
> 
> The templates that handle this piece go like this:
> 
> <xsl:template match="family">
> <!--    Some HTML formatting (blah blah)-->
>      <xsl:apply-templates select=".//channelId"/>
> <!--    Some HTML formatting (blah blah)-->
> </xsl:template>
> 
> <xsl:template match="channelId">
>      <xsl:variable name="myId" select="."/>
>      <xsl:variable name="isA" select="name($canal/..)"/>

You hven't told us what $canal is!

>   <!-- take the entire "channel" from database -->
>      <xsl:variable name="createQuery"
> select="concat('retrieveCompleteChannel','?',channel=',$myId)"/>
>   <xsl:variable name="show" select="document($createQuery)"/>

You're retrieving another document from the database here, but you haven't
told us what's in it!
> 
>  <xsl:call-template name="listing">
>   <!-- some formating params -->
>   <xsl:with-param name="toList" select="$show//completeChannel"/>
>   <xsl:with-param name="isA" select="$isA"/>
>  </xsl:call-template>

You haven't told us what's in $show.
> 
> </xsl:template>
> 
> <xsl:template name="listing">
>  <!-- some formating params -->
>  <xsl:param name="toList" select="$default//completeChannel"/>

You haven't told us what's in $default.

>  <xsl:param name="isA" select="string('none')"/>
>  <xsl:if test='count($toList/published)>0'>
> <!--    Some HTML formatting using isA -->
>   <xsl:value-of select="$toList/desc"/> - <xsl:number/> <!-- show the
> number -->
> <!--    Some HTML formatting using isA -->
>  </xsl:if>
> </xsl:template>
> 
> The "listing" template is part of a library that's used 
> everywhere on the
> system. I can change it only if it can be used in the rest of 
> the templates
> (i.e. adding a param to indicate it's my template the one 
> that's calling
> it).
> As an example output, let's say "ch1" and "ch3" complete 
> channels has no
> elements inside, I would like to see on my output the following:
> 
>   Channel 2 - 1
>   Channel 4 - 2
>   Channel 5 - 3

I don't understand the relationship of this output to your input. Where do
the numbers 2,4,5 (and 1,2,3) come from?

> 
> ps: If my Grammar makes the question difficult to understand, 
> I will try to
> clarify.

It's difficult to understand the question, but the problem is nothing to do
with your grammar, which is perfect!

Michael Kay

Current Thread