[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: parent of child
Joe, >if in my code user selected node <b>, how can i detect the parent of <b>; >which in this case is node <a>?. Basicly i want to change the display of ><a> when someone select <b> >From the sounds of this I'm a little worried that you're asking about using some JavaScript or something rather than XSL - what do you mean by a user selecting a node? >How can I find out the parent of a select child from XSL? In case you *are* asking a question about XSLT, I'm translating this as 'how can I find out the parent of the current node within XSL?' The answer is that you use the 'parent' axis. >for example, I have the following XML : > > <a>Test</a> > <b>Test2</b> > <b2>Test3</b2> > </a> I will assume that you mean: <a>Test <b>Test2</b> <b2>Test3</b2> </a> If you have a template that matches the 'b' element, then within it you can select the 'a' element for processing using the XPath 'parent::node()' or simply '..'. For example: <xsl:template match="b"> <xsl:apply-templates select="parent::node()" /> </xsl:template> Or <xsl:template match="b"> <xsl:apply-templates select=".." /> </xsl:template> Note that unless you specify a template for 'a' that doesn't move on to process the 'b' element, you will get into an infinite loop, so watch out! I hope this helps, Jeni Dr Jeni Tennison Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE Telephone 0115 9061301 ? Fax 0115 9061304 ? Email jeni.tennison@xxxxxxxxxxxxxxxx XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|