我有一个这样的 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 转换,它将在 title 元素之后更改每个<p>
元素的元素名称(title 元素之后的第一个 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>
我找不到允许我选择此类元素的模板选择表达式,因为它不允许我使用兄弟轴。
有什么建议么?