我正在尝试使用 XSLTcontext-param
作为最后一个兄弟姐妹。没有共同的父元素,所以任务有点难。
我想附加以下元素:
<context-param>
<param-name>miku</param-name>
<param-value>kawaii</param-value>
</context-param>
作为以下 xml 中的最后一个context-param
元素(例如,所有context-param
元素必须彼此相邻,它们不能分散在 xml 中的任何位置):
<web-app>
<not_interesting_element1/>
<not_interesting_element2/>
<context-param>
<param-name>not_interesting_param_key1</param-name>
<param-value>kawaii</param-value>
</context-param>
<context-param>
<param-name>not_interesting_param_key2</param-name>
<param-value>kawaii</param-value>
</context-param>
<context-param>
<param-name>parameterThatsGuaranteedToBeHere</param-name>
<param-value>someValue</param-value>
</context-param>
<not_interesting_element3/>
<not_interesting_element4/>
<!-- ... servlets, ... -->
</web-app>
结果应如下所示:
<web-app>
<not_interesting_element1/>
<not_interesting_element2/>
<context-param>
<param-name>not_interesting_param_key1</param-name>
<param-value>kawaii</param-value>
</context-param>
<context-param>
<param-name>not_interesting_param_key2</param-name>
<param-value>kawaii</param-value>
</context-param>
<context-param>
<param-name>parameterThatsGuaranteedToBeHere</param-name>
<param-value>someValue</param-value>
</context-param>
<context-param>
<param-name>miku</param-name>
<param-value>kawaii</param-value>
</context-param>
<not_interesting_element3/>
<not_interesting_element4/>
<!-- ... servlets, ... -->
</web-app>
请问我该怎么做?