xsl-list
[Top] [All Lists]

Re: Use of xsl:number, ignoring some elements

2004-08-04 07:15:19
Thanks for your answer. I will try to explain it better.



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.

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

The ones I want to ignore are the ones that, when I retrieve the "second"
document, this one have no elements inside. But I can't tell that until I've
retrieved that document, and the "count" attribute doesn't allow me to use
the elements retrieved. I tryed to explain that in the following lines, but
it seems I took too many things as known. Thanks for make me see I wasn't
given all the needed info. Let's see if I can make it better this time.

<xsl:template match="channelId">
     <xsl:variable name="myId" select="."/>
     <xsl:variable name="isA" select="name($canal/..)"/>

MK > You hven't told us what $canal is!

"$canal" is the "original" name (I've forgotten to translate it!) to the
document I've put below as "$default". When I retrieve all that "family"
structure I've listed above, it's only a part of  $default document. The
structure on that document includes descriptive data (id, description, max
number of contents allowed, and so on) for the "current" channel  I'm
listing, the "family tree", a block with all the contents it has, and some
other things I don't even know what are they for... used in other parts of
the system, I think.


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

MK > You're retrieving another document from the database here, but you
haven't told us what's in it!

The same as I've described above. It's the same query used for the current
channel, now applied to its children and siblings. The structure is
something like this:

<some database info/>
<some database info/>
<some database tags>
...
<results>
    <completeChannel>
        <channelId>ch1</channelId>
        <desc>Channel 1</desc>
        <otherInfo/>
        <family/>
        <dontKnowWhatItIs/>
        <dontKnowWhatItIs/>
        <dontKnowWhatItIs/>
        <dontKnowWhatItIs/>
    </completeChannel>
</results>
...
</some database tags>
<some database info/>

If there is any  "content" published on the "channel", then after the
<family/> tag you would see  this:

<published>
    <content>
        <contentId>content1</contentId>
        <title>My pretty content</title>
    </content>
    <content>
        <contentId>content2</contentId>
        <title>Hi World!</title>
    </content>
    <content>
        <contentId>content3</contentId>
        <title>Yepee!</title>
    </content>
</published>



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

MK > You haven't told us what's in $show.

Just in case, the use of "//" in  "$show//completeChannel" is something I
need because it depends on the version of the database the amount of tags
between the <?xml ... > tag and the "completeChannel" one. Some versions
include more information about the query than others.


</xsl:template>

<xsl:template name="listing">
 <!-- some formating params -->
 <xsl:param name="toList" select="$default//completeChannel"/>

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

In other templates of the stylesheet, I'm using the same template to show
the "contents" of the current channel. As this template is used in other XSL
stylesheets as well, and I don't want to have to make a copy of it because
it could be really difficult to maintain, I've decided to convert the former
"toList" variable it was using into a parameter, and use the "current
channel" document  as its default value. I'm not sure it's best practice,
but at this moment it's the only way I could think to avoid duplication.


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



  Channel 2 - 1
  Channel 4 - 2
  Channel 5 - 3


MK > 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?

The "Channel n" part is the description of the channel, taken from the
structure I've described above (and I completely forgot in my first
message). 1,2,3 are the "xsl:number" (or any other way it can be achieved)
generated numbers. In all the other stylesheet that are using this "listing"
template, the structure "allways" has the "published" tag with all the
contents inside, and that's why they don't have this problem and the
generated number never "jumps". Only now that I have to take the "family"
channels into account, I have this problem.

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

Thanks! I think the problem is that I've been going around with this case so
much that I've think everybody in the world knows all the little details on
it ;)


Marina Cuello




<Prev in Thread] Current Thread [Next in Thread>
  • Re: Use of xsl:number, ignoring some elements, Marina Cuello <=