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 July 26th, 2012, 03:02 PM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 59
Thanks: 12
Thanked 0 Times in 0 Posts
Default XPath To Siblings

Hello.

Here's an example of my XML file.
Code:
<doc>
 <EOB>
  <DETAIL>
   <DETAILLINE>
    <RCDATA>
     <RCDATALINE>
      <RC>01</RC>
     </RCDATALINE
     <RCDATALINE>
      <RC>02</RC>
     </RCDATALINE
    </RCDATA>
    <CRCDATA>
     <CRCDATALINE>
      <CRC>AA</CRC>
     </CRCDATALINE>
     <CRCDATALINE>
      <CRC>AB</CRC>
     </CRCDATALINE>
    </CRCDATA>
   </DETAILLINE>
   <DETAILLINE>
    <RCDATA>
     <RCDATALINE>
      <RC>03</RC>
     </RCDATALINE
     <RCDATALINE>
      <RC>04</RC>
     </RCDATALINE
    </RCDATA>
    <CRCDATA>
     <CRCDATALINE>
      <CRC>AC</CRC>
     </CRCDATALINE>
     <CRCDATALINE>
      <CRC>AD</CRC>
     </CRCDATALINE>
    </CRCDATA>
   </DETAILLINE>
  </DETAIL  
 </EOB>
</doc>
What I need to accomplish is this:
I have a for-each loop on the <DETAILLINE>.
Within this loop I have another for-each loop on the <RCDATALINE>.
In this second loop if <RC> is not empty then I need to check <CRCDATALINE><CRC> that it's not empty.

I've tried using following-sibling without any success.
Here's my partial code.
Code:
<xsl:for-each select="DETAILLINE">
 <xsl:for-each select="RCDATA/RCDATALINE">
    <xsl:if test="RC[.!='']>
      <xsl:if test="(following-sibling::*/CRCDATA/CRCDATALINE/CRC[.!='']>
This does not work because following-sibling probably applies to <RCDATALINE> and I need it to apply to be the following-sibling of <RCDATA>.

Any help will be greatly appreciated!

Thanks,
Rita
Reply With Quote
  #2 (permalink)  
Old July 26th, 2012, 04:00 PM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2010
Posts: 59
Thanks: 12
Thanked 0 Times in 0 Posts
Default

I finally got it to work using this code:
<xsl:if test="(../../CRCDATA/CRCDATALINE/CRC[.!=''])">
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
how to get siblings and parents eruditionist XSLT 7 June 29th, 2011 03:00 PM
some help wanted with grouping following siblings wokoman XSLT 10 May 13th, 2011 02:13 PM
Grouping following siblings bonekrusher XSLT 5 November 19th, 2009 02:30 PM
Problem accessing the following siblings. Tre XSLT 6 June 5th, 2007 11:13 AM
Comparing siblings Chamkaur XSLT 1 June 17th, 2006 09:56 PM



All times are GMT -4. The time now is 01:50 PM.


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