Mega Code Archive

 
Categories / XML / XSLT StyleSheet
 

Parent and attribute

File: Data.xml <wine grape="A">   <winery>B</winery>   <year>1998</year>   <prices>     <list>13.99</list>     <discounted>11.99</discounted>     <case>143.50</case>   </prices> </wine> File: Transform.xslt <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"   version="1.0">   <xsl:output method="xml" omit-xml-declaration="yes" indent="no" />   <xsl:template match="prices">     parent element's grape:     <xsl:value-of select="parent::wine/attribute::grape" />   </xsl:template>    </xsl:stylesheet> Output:   B   1998        parent element's grape:     A