Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 22nd, 2005, 11:54 AM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default preceding-sibling

i have an xsl problem

below is part of my xml file

- <table width="100%" border="0" cellspacing="0" cellpadding="2">
- <tr valign="top">
- <td align="left" class="grid">
  <b>22:35</b>
  <br />
  <a class="grid" href="javascript:dtl('1326097');">The National Lottery: Midweek Draws</a>
  <br />
  Ian Wright presents the midweek...
  </td>
  </tr>
  </table>
- <table width="100%" border="0" cellspacing="0" cellpadding="2">
- <tr valign="top">
- <td align="left" class="grid">
  <b>22:45</b>
  <br />
  <a class="grid" href="javascript:dtl('1326112');">Car Wars</a>
  <br />
  In the first of a two-part investigation...
  </td>
  </tr>
  </table>

i need to use preceding-sibling:: to jump from the 2nd a class tag up to the first a class tag


this is the code so far how ever only shows the imidiate tag above
where am i going wrong

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="C:\cw2004\sample.xsl"?>
<xsl:stylesheet version="1.0" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:template match="h:a[contains(text(),'Car')]">
        #160;

        <xsl:value-of select="preceding-sibling::*"/>
        </xsl:template>
   <xsl:template match="text()"/>
</xsl:stylesheet>


 
Old November 22nd, 2005, 12:06 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

>i need to use preceding-sibling:: to jump from the 2nd a class tag up to the first a class tag

That's a bit like saying "I need to get from Berlin to Moscow by ferry". The two <a> elements aren't siblings, so you can't use preceding-sibling to get from one to the other.

Try

preceding::a[1], or

ancestor::table/preceding-sibling::table[1]//a



Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old November 22nd, 2005, 12:29 PM
Registered User
 
Join Date: Nov 2005
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Still no joy, bascally i need to navigate from one section to another, not sure how to do it





Similar Threads
Thread Thread Starter Forum Replies Last Post
preceding-sibling::comment() bonekrusher XSLT 11 October 1st, 2008 11:38 AM
Using preceding-sibling mcanne98 Infopath 0 September 11th, 2008 11:09 PM
Preceding-sibling question. lafilip XSLT 7 March 5th, 2007 12:35 PM
preceding-sibling behaviour andrewcday XSLT 6 December 3rd, 2004 03:24 PM
sorting and preceding-sibling iamhigh XSLT 5 August 25th, 2003 12:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.