开发者

Find parent tag xslt

开发者 https://www.devze.com 2023-02-28 18:48 出处:网络
How to get the parent node of a particular tag type . For ex- Input XML is below- <table type=\"SPECIALMATERIALtbl\" UID=\"2001\">

How to get the parent node of a particular tag type . For ex- Input XML is below-

<table type="SPECIALMATERIALtbl" UID="2001">
    <row class="FIGURE" type="SPECIALMATERIALrow">
      <cell class="FIGURE" colspan="7">
        This is a cell
      </cell>
    </row>
   </table>

So, I want to get the type attribute of 'table' element above when I am inside the cell template in XSLT. I want to do this only for开发者_JAVA百科 parent element of type - 'table' . So the output to above should be- "SPECIALMATERIALtbl"

Awaiting a response.


With <cell> being the context node, <xsl:value-of select="ancestor::table/@type"/> returns what you want.

0

精彩评论

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