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(_at_)lists(_dot_)mulberrytech(_dot_)com>
<jstuardo(_at_)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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--