Het volgende probleem:
ik wil van de onderstaande xml
[code]
<cols>
<col1>
<rows>
<row1>
<name>name1</name>
<description>description1</description>
</row1>
<!-- other row1s -->
</rows>
</col1>
<col2>
<rows>
<row2>
<name>name2</name>
<description>description2</description>
</row2>
<!-- other row2s -->
</rows>
</col2>
<col3>
<rows>
<row3>
<name>name3</name>
<description>description3</description>
</row3>
<!-- other row3s -->
</rows>
</col3>
</cols>
[code]
omzetten naar
ik wil het bovenstaande resultaat met de volgende xslt template bereiken:
Het bovenstaand werkt template doorloopt alleen alle cols/col1/rows/row1.
Het is de bedoeling dat de template ook alle cols/col2/rows/row2 en cols/col3/rows/row3 rijen doorlopen maar met huidige xslt kennis weet ik niet hoe ik dit moet bereiken.
Kan iemand mij misschien de juist richting wijzen?
ik wil van de onderstaande xml
[code]
<cols>
<col1>
<rows>
<row1>
<name>name1</name>
<description>description1</description>
</row1>
<!-- other row1s -->
</rows>
</col1>
<col2>
<rows>
<row2>
<name>name2</name>
<description>description2</description>
</row2>
<!-- other row2s -->
</rows>
</col2>
<col3>
<rows>
<row3>
<name>name3</name>
<description>description3</description>
</row3>
<!-- other row3s -->
</rows>
</col3>
</cols>
[code]
omzetten naar
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
| <table border="1">
<!-- a row -->
<tr>
<table border="1">
<tr>
<!-- col1 -->
<td>col1/row1/name</td>
<!-- col2 -->
<td>col2/row2/name</td>
<!-- col3 -->
<td>col3/row3/name</td>
</tr>
<tr>
<!-- col1 -->
<td>col1/row1/description</td>
<!-- col2 -->
<td> col2/row2/description</td>
<!-- col3 -->
<td> col3/row3/description</td>
</tr>
</table>
</tr>
<!-- other rows -->
</table> |
ik wil het bovenstaande resultaat met de volgende xslt template bereiken:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
| <xsl:template name="cols">
<html>
<head>
<title>Untitled Page</title>
</head>
<body>
<table border="1">
<xsl:for-each select="/cols/col1/rows/row1">
<xsl:variable name="row1Pos" select="position()"/>
<!-- a row -->
<tr>
<table border="1">
<!-- name -->
<tr>
<!-- col1 -->
<td>
<xsl:value-of select="name[position() = $row1Pos]"/>
</td>
<!-- col2 -->
<td>
<xsl:value-of select="/cols/col2/rows/row2/name[position() = $row1Pos]"/>
</td>
<!-- col3 -->
<td>
<xsl:value-of select="/cols/col3/rows/row3/name[position() = $row1Pos]"/>
</td>
</tr>
<tr>
<!-- col1 -->
<td>
<xsl:value-of select="/cols/col1/rows/row1/description[position() = $row1Pos]"/>
</td>
<!-- col2 -->
<td>
<xsl:value-of select="/cols/col2/rows/row2/description[position() = $row1Pos]"/>
</td>
<!-- col3 -->
<td>
<xsl:value-of select="/cols/col3/rows/row3/description[position() = $row1Pos]"/>
</td>
</tr>
</table>
</tr>
<!-- other rows -->
</xsl:for-each>
</table>
</body>
</html>
</xsl:template> |
Het bovenstaand werkt template doorloopt alleen alle cols/col1/rows/row1.
Het is de bedoeling dat de template ook alle cols/col2/rows/row2 en cols/col3/rows/row3 rijen doorlopen maar met huidige xslt kennis weet ik niet hoe ik dit moet bereiken.
Kan iemand mij misschien de juist richting wijzen?