Subject: RE: [xsl] How to get the sibling node just before the context node? From: "Jaime Stuardo" <jstuardo@xxxxxxxxxxx> Date: Thu, 21 Apr 2005 09:15:10 -0400 |
Hi... that XML was only an example. The real XML is very more complex and I can assure is well formed. One difference between the example XML and the real one is that A = B = C = ROW. To get the actual nodes listed in rows I'm doing: .... <xsl:apply-templates select="ROW" /> .... <xsl:template match="ROW"> <xsl:value-of select="TEXT1" /> - <xsl:value-of select="{I WANT TO PLACE HERE TEXT1 OF THE PRECEDING NODE}" /> </xsl:template> Thanks Jaime -----Mensaje original----- De: omprakash.v@xxxxxxxxxxxxx [mailto:omprakash.v@xxxxxxxxxxxxx] Enviado el: Jueves, 21 de Abril de 2005 2:13 Para: xsl-list@xxxxxxxxxxxxxxxxxxxxxx Asunto: Re: [xsl] How to get the sibling node just before the context node? 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, Jarno.Elovirta | Thread | RE: [xsl] How to get the sibling no, omprakash . v |
Re: [xsl] write out xml *with* tags, David Carlisle | Date | [xsl] trying to figure out date fun, xml |
Month |