使用 XSLT 修改嵌入其他元素文本中的元素
由于我可能会搞乱术语,因此我将通过示例进行解释。
我的 XML 源文档包含如下元素:
<paragraph>
This paragraph has things like <link><xref label="lbl1">this</xref></link>
and things like <emphasis type="bold">this</emphasis>
and <emphasis type="italic">this</emphasis>.
</paragraph>
需要使用 XSLT 将其转换为:
<p>
This paragraph has things like <a href="[lbl1]">this</a>
and things like <b>this</b>
and <i>this</i>.
</p>
谢谢!
Since I would probably botch up the terminology, I'll explain by example.
My XML source document contains elements like this:
<paragraph>
This paragraph has things like <link><xref label="lbl1">this</xref></link>
and things like <emphasis type="bold">this</emphasis>
and <emphasis type="italic">this</emphasis>.
</paragraph>
Need to use XSLT to transform that to:
<p>
This paragraph has things like <a href="[lbl1]">this</a>
and things like <b>this</b>
and <i>this</i>.
</p>
Thanks!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当前的两种解决方案太长,其中一种甚至不是格式良好的 XML...
这是一个简短而完整的解决方案:
当此转换应用于提供的 XML 文档时:
产生了想要的正确结果:
The current two solutions are too-long and one of them is not even well-formed XML...
Here is a short and complete solution:
when this transformation is applied on the provided XML document:
the wanted, correct result is produced:
这应该可以解决问题:
This should do the trick: