我在我的 xhtml 的命名空间 x 中定义了一对自定义的自结束标签 s1 和 s2。对于具有相同 id 的每个标签对 s1、s2,我想将 span 标签添加到它们之间的所有文本节点。每个 s1、s2 标签对都有一个唯一的 id。我正在寻找基于 XSL 的解决方案。我正在为 XSL 使用 Saxon java 处理器。
样本输入:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is my title</title>
</head>
<body>
<h1 align="center">
This is my heading
</h1>
<p>
Sample content Some text here. Some content here.
</p>
<p>
Here you go.
</p>
</body>
</html>
样本输出:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>This is my title</title>
</head>
<body>
<h1 align="center">
This <span class="spanClass" id="1">is my</span>heading
</h1>
<p>
Sample content <span class="spanClass" id="2">Some text here. Some content here.</span>
</p>
<p>
<span class="spanClass" id="3">Here you</span>go.
</p>
</body>
</html>