【发布时间】:2013-10-03 00:41:46
【问题描述】:
我有一个这样的 XML 文件:
<section>
<section>
<title>this is title 1</title>
<p> first paragraph after the title for which I need to change the element name </p>
<p>second paragraph</p>
<p>second paragraph</p>
</section>
<section>
<p>paragraph</p>
<title>this is title 1</title>
<p> first paragraph after the title for which I need to change the element name </p>
<p>second paragraph</p>
<p>second paragraph</p>
</section>
</section>
我需要找出一个 XSL 转换,它将在标题元素之后(标题元素之后的第一个 p 元素)更改每个 <p> 元素的元素名称。
这个想法是,转换后的输出 xml 应该如下所示:
<section>
<section>
<title>this is title 1</title>
<p_title> first paragraph after the title for which I need to change the element name </p_title>
<p>second paragraph</p>
<p>second paragraph</p>
</section>
<section>
<p>paragraph</p>
<title>this is title 1</title>
<p_title> first paragraph after the title for which I need to change the element name </p_title>
<p>second paragraph</p>
<p>second paragraph</p>
</section>
</section>
我找不到允许我选择此类元素的模板选择表达式,因为它不允许我使用兄弟轴。
有什么建议吗?
【问题讨论】: