【发布时间】:2022-01-23 03:15:45
【问题描述】:
在这里,我需要每个学生通过 id_promo 摸索他的模块,但是 我不知道 for each with condition and loop in loop 的语法
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs"
version="2.0">
<xsl:template match="/">
<html>
<head>
</head>
<body>
<h1>Liste des Etudiants et les module de promo</h1>
<ul>
<table width="80%" border="1px" cellpadding="10px" cellspacing="0px">
<thead>
<th>num_et</th><th>nom_et</th><th>prenom_et</th><th>nom_mod</th><th>id_mod</th>
</thead>
<tbody>
<xsl:for-each select="promotion/etudiants/etudiant">
<tr>
<td><xsl:value-of select="@num_et"/></td>
<td><xsl:value-of select="@nom_et"/></td>
<td><xsl:value-of select="@prenom_et"/></td>
</tr>
</xsl:for-each>
</tbody>
</table>
</ul>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
<?xml version="1.0" encoding="iso-8859-1"?>
<promotion option="MGL" niveau="2" >
<etudiants>
<etudiant numInscription="3666" nom="X" prenom="Y" id_promo="1"/>
.....
......
</etudiants>
<modules>
<module idModule="E200" nomModule="Web 2.0" id_promo="1"/>
<module idModule="E222" nomModule="Web 3.0" id_promo="1"/>
......
......
</modules>
</promotion>
| Name | prename | module |
|---|---|---|
| X | Y | Web 2.0 |
| Web 3.0 |
【问题讨论】:
-
请就您在尝试完成此操作时遇到的困难提出一个具体问题。否则,看起来您只是在寻找某人为您编写代码。 -- 提示:使用key 来解析交叉引用。
-
困难在于:在我的文档 xml 中有许多
节点,每个节点学生都有许多 ,将 XML 文件转换为每个标签所需的 HTML 表 name_mod 的许多标签 ,例如循环内循环,或 for_each 内的 for_eache,但这不起作用 我们需要的那个表:SELECT num_et,nom_et,prenom_et,nom_mod FROM etudiant,modules WHERE etudiant.id_promo=modules.id_promo;请编辑您的问题并添加您当前的尝试和预期结果(作为 HTML 代码)。我想现在很清楚了