Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 July 26th, 2012, 03:02 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
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
 
Old July 26th, 2012, 04:00 PM
Authorized User
 
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default

I finally got it to work using this code:
<xsl:if test="(../../CRCDATA/CRCDATALINE/CRC[.!=''])">





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





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