开发者

XSLT modify node before applying template

开发者 https://www.devze.com 2023-01-03 18:15 出处:网络
I have an XSL code that processes some nodes and if some condition is true, before doing apply-template select=\".\" i need to modify current node(add and attribute).

I have an XSL code that processes some nodes and if some condition is true, before doing apply-template select="." i need to modify current node(add and attribute).

How can i add an attribute开发者_开发问答 to the node before calling apply-template select=".", or it is not possible at all ?


You can have two transformations applied -- the first copies every node as is, but only adds the necessary attribute to the node in question. Then the second transformation is applied on the result of the first transformation.

Another way is to leave the addition of the attribute to the templates that are applied with <xsl:apply-templates select="."/>


If you are using the Microsoft XSLT processor then you can use msxsl:node-set function to copy and modify your node if you really really have to pass through the node with your modified attribute, but I would personally opt for Dimitre's method above.

http://msdn.microsoft.com/en-us/library/hz88kef0(v=vs.71).aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号