Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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>


Reply With Quote
  #2 (permalink)  
Old November 22nd, 2005, 12:06 PM
mhkay's Avatar
Wrox Author
Points: 18,481, Level: 59
Points: 18,481, Level: 59 Points: 18,481, Level: 59 Points: 18,481, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,960
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
Reply With Quote
  #3 (permalink)  
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

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 10:34 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.