xsl-list
[Top] [All Lists]

RE: [xsl] Using XSLT 1.0 , I have tried using the Meunchian methodsolutions on

2006-12-19 16:58:31
I thought he was already using nested loops?  The outer looped through
the nodes selected by the key, then the inner iterated through all nodes
selected by the key using the FilingType of the context node in the
outer loop.  Since he wished to display AgencyName once in the inner
loop, using position() should be appropriate there.  I could have
misread the original post, of course.

Cheers,
b.

-----Original Message-----
From: Wendell Piez [mailto:wapiez(_at_)mulberrytech(_dot_)com]
Sent: Tuesday, December 19, 2006 4:39 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] Using XSLT 1.0 , I have tried using the Meunchian
methodsolutions on

At 05:01 PM 12/19/2006, you wrote:
A quick and dirty way:

<xsl:if test="position() = 1">
        <div>
            <xsl:value-of select="AgencyName"/>
      </div>
</xsl:if>

This will display AgencyName only on the first occurrence of the
nodes
selected by your key.

Not really. It'll display AgencyName only if the current node of the
instruction is the first node among the current node list --
something which only has to do with the order of the nodes you select
by your key if you control for this. If you don't, and it works, it's
working by accident.

  Note, however, that your key only groups by
FilingType--if you have multiple AgencyNames with the same FilingType
only the first occurrence of AgencyName will appear.

You can fix this by expanding your key:

  <xsl:key name="tar_by_filingtype" match="MonthlyTARList"
use="concat(FilingType, ' ', AgencyName)"/>

Then change your for-each to use

key('tar_by_filingtype', concat(FilingType, ' ', AgencyName))

Using an explicit for-each instruction around the xsl:if clause will
provide the needed control to make sure position() works properly ...
but it's then safer just to select the first one in document order
explicitly:

<xsl:for-each
   select="key('tar_by_filingtype', concat(FilingType, ' ',
AgencyName))[1]">
   <!-- note predicate in select expression -->
   <div>
     <xsl:value-of select="AgencyName"/>
   </div>
</xsl:for-each>

Cheers,
Wendell



======================================================================
Wendell Piez                            
mailto:wapiez(_at_)mulberrytech(_dot_)com
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
   Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>