xsl-list
[Top] [All Lists]

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

2007-08-11 13:02:00
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(_at_)yahoo(_dot_)com> 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[(_at_)i]">
  <xsl:variable name="vInum">
    <xsl:number count="A[(_at_)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[(_at_)i]", it will sum up all preceding "A[(_at_)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

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