html - 使用 xslt 从 xml 获取 HTML 列表中的值
问题描述
下面有两个 XML 列表 ( sub1
, sub2
)。我们可以编写一个 XSLT 来将它们转换为带有ol
标签的 HTML 吗?
<sub1>
<number>(1)</number>
<para-text align="left" indent="0">XYZ</para-text>
<sub2>
<number>(a)</number>
<para-text align="left" indent="0">ABC</para-text>
</sub2>
<sub2>
<number>(b)</number>
<para-text align="left" indent="0">DEF</para-text>
</sub2>
<sub2>
<number>(c)</number>
<para-text align="left" indent="0">GHI</para-text>
</sub2>
</sub1>
我使用了以下模板(当前节点的值),但未能成功。
<xsl:template match="/sub1">
<ol>
<li>
<xsl:for-each select="para-text">
<xsl:value-of select="current()" /> </xsl:for-each>
</li>
</ol>
</xsl:template>
我正在寻找的 HTML 结构就像
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<ol>
<li></li>
<li></li>
</ol>
</body>
</html>
解决方案
推荐阅读
- c# - 如何创建特定(大)大小的对象?
- javascript - 货币符号和金额 html 模式的正则表达式
- c# - 不支持给定路径的格式 - 使用时间数据
- typescript - 如何使用 Redux 类型将返回类型转换为 void?
- python - 不明白这个 TypeError:+ 的不支持的操作数类型:'NoneType' 和 'float'
- c# - C# Winforms 处理未处理的异常
- python - 有什么方便的方法来获取页面中子部分的索引吗?
- javascript - 提交表单时键盘消失
- c# - 访问在另一个 Windows 窗体中创建的 Windows 窗体的属性
- haskell - 什么是特定于 list 的同构类型,它是如何实现的?