Subject: Re: [xsl] How to get the sibling node just before the context node? From: omprakash.v@xxxxxxxxxxxxx Date: Thu, 21 Apr 2005 11:43:01 +0530 |
Hi, Your xml is not well-formed due to 2 reasons. 1. All elements in your XML must be a child of a root element 2. Th Text1 and Text2 elements do not have matching closing tags. Having said that, the following stylesheet should do what you want. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" indent="yes" /> <xsl:template match="/X"> <xsl:apply-templates select="C"/> </xsl:template> <xsl:template match="C"> <xsl:value-of select="preceding-sibling::B[1]"/> </xsl:template> </xsl:stylesheet> And the input XML I used was <?xml version="1.0" encoding="UTF-8"?> <X> <A> <TEXT1> at1 </TEXT1> <TEXT2> at2 </TEXT2> </A> <B> <TEXT1> t1</TEXT1> <TEXT2>t2 </TEXT2> </B> <C> <TEXT1> ct1 </TEXT1> <TEXT2> ct2</TEXT2> </C> </X> Cheers, Omprakash.V "Jaime Stuardo" To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> <jstuardo@sec cc: (bcc: omprakash.v/Polaris) urity.cl> Subject: [xsl] How to get the sibling node just before the context node? 04/21/2005 04:26 AM Please respond to xsl-list For example, <A> <TEXT1> <TEXT2> </A> <B> <TEXT1> <TEXT2> </B> <C> <TEXT1> <TEXT2> </C> If context node is C, I want to get only B. I tried using preceding-sibling::TEXT1 but I always get TEXT1 of node A, but I want to get it of node B. Thanks in advance Jaime This e-Mail may contain proprietary and confidential information and is sent for the intended recipient(s) only. If by an addressing or transmission error this mail has been misdirected to you, you are requested to delete this mail immediately. You are also hereby notified that any use, any form of reproduction, dissemination, copying, disclosure, modification, distribution and/or publication of this e-mail message, contents or its attachment other than by its intended recipient/s is strictly prohibited. Visit Us at http://www.polaris.co.in
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] How to get the sibling no, Michael Kay | Thread | RE: [xsl] How to get the sibling no, Jarno.Elovirta |
Re: [xsl] How to get the sibling no, Ramkumar Menon | Date | RE: [xsl] How to get the sibling no, Jarno.Elovirta |
Month |