xsl-list
[Top] [All Lists]

RE: Grouping data

2003-01-16 10:08:36
There's a couple things you'll want to look at:

The 'position()' function: When you're processing a list of nodes, this 
function gives you the number of the current node in the list.  So if you were 
processing all the <item> nodes using the '<xsl:for-each>' element, position() 
would tell you which item you were on.

For actually creating nodes, look at the '<xsl:element>' element.

You can find many examples of how to use this stuff in the archives of this 
list.

Hope I was some help,
Andy

-----Original Message-----
From: Daniel Rodríguez Díaz [mailto:danielr(_at_)sogecable(_dot_)com]
Sent: Thursday, January 16, 2003 9:10 AM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] Grouping data


Hi,
I've got an xml document with 5 nodes and I try to transform it from xml 
into html in the following way:
I want to put the first 3 nodes inside a <p></p> using certain template, 
the rest inside a <div></div> using a different template.

I know how to manage the elements and count them but I don't know how to 
create a node including templates when I'm in the first or third node.

Here is an example to explain better:


XML

<raiz>
<item>
<nombre>Uno</nombre>
<apellidos>1111</apellidos>
</item>
<item>
<nombre>Dos</nombre>
<apellidos>2222</apellidos>
</item>
<item>
<nombre>Tres</nombre>
<apellidos>3333</apellidos>
</item>
<item>
<nombre>Cuatro</nombre>
<apellidos>4444</apellidos>
</item>
<item>
<nombre>Cinco</nombre>
<apellidos>5555</apellidos>
</item>
</raiz>


HTML

<p>
<h1>Uno</h1><h2>1111</h2>
<h1>Dos</h1><h2>2222</h2>
<h1>Tres</h1><h2>3333</h2>
</p>
<div>
<h3>Cinco</h3>
<h3>Cinco</h3>
</div>

Thanks in advance


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>
  • Grouping data, Daniel Rodríguez Díaz
    • RE: Grouping data, Andy J. Cupp <=