Re: [xsl] While copying everything, append attribute value with incremental index.

Subject: Re: [xsl] While copying everything, append attribute value with incremental index.
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sat, 11 Aug 2007 13:01:41 -0700
> However, can you explain the logic of the code that you provided:


I am afraid you will need to read about the <xsl:number .../>
instruction. Generally it is used to

    "allocate a sequential number to the current node"
    (from the XSLT 2.0 book of Dr. Kay).


-- 
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play

On 8/11/07, Xuan Ngo <xuanngo2001@xxxxxxxxx> wrote:
> Thank you Dimitre Novatchev for your explanation of the position().
>
> However, can you explain the logic of the code that you provided:
>  <xsl:template match="A[@i]">
>   <xsl:variable name="vInum">
>     <xsl:number count="A[@i]"/>
>   </xsl:variable>
>   <A i="{concat(@i,'_',$vInum)}">
>          <xsl:apply-templates select=
>            "@*[not(name()='i')]
>            |
>             node()
>            "
>          />
>    </A>
>  </xsl:template>
> --------------------------
> I will take a shot here. Tell me if I am right. Each time that it encounters the condition
> "A[@i]", it will sum up all preceding "A[@i]". Hence, creating an incremental index(1,2,3,...).
> Then, it assigns the sum to the variable vInum so that later it can be used to create the element
> A. Since the code is creating the attribute i then it shouldn't copy it. Hence, the condition
> "[not(name()='i')]"
>
> thx!
>
>
>
> ____________________________________________________________________________________
> Boardwalk for $500? In 2007? Ha! Play Monopoly Here and Now (it's updated for today's economy) at Yahoo! Games.
> http://get.games.yahoo.com/proddesc?gamekey=monopolyherenow

Current Thread