xsl-list
[Top] [All Lists]

Re: [xsl] apply-templates repeats inside xsl:for-each, why

2014-06-15 20:46:27
Ummm .. maybe I'm missing something, but isn't that exactly the same as

    <xsl:apply-templates select="$root/map/concept/concept[ @id = 
$platforms/platform/@id ]"/>

?

(I'm too tired right now to explain this well, and many on this list
are much better than I at explaining such things, but basically that
says "select each /map/concept/concept that has an id= that is the
same as the id= of one of the $platforms/platform elements, and apply
templates to it". That is the "/map/concept/concept" grabs all of the
<concept> elements that are children of a <concept> that are in turn
children of the <map>, and the predicate selects only those that meet
the condition. But the '=' comparison operator works on sequences,
and the condition returns true for all 3.)


I fixed it for my purposes by doing it this way:

         <xsl:variable name="num"
         select="count($platforms/platform)"/> <xsl:for-each
         select="1 to $num">
           <xsl:variable name="n" select="position()"/>
           <xsl:apply-templates select="$root/map/concept/concept[@id
           =
$platforms/platform[$n]/@id]"/>
         </xsl:for-each>

Then I get the output just once like this:

Windows XP
Windows Vista
Windows 7

Thanks for the help in breaking some adhesions.
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

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