View Single Post
  #1 (permalink)  
Old May 6th, 2020, 07:00 PM
ritagr ritagr is offline
Authorized User
Points: 323, Level: 6
Points: 323, Level: 6 Points: 323, Level: 6 Points: 323, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Apr 2010
Posts: 61
Thanks: 12
Thanked 0 Times in 0 Posts
Default Determine If Previous Element Matches Current Element


I have the following XML code:
        <LINE>This is my explanation line</LINE>
Here is what I need to accomplish:
For each unique <DETAILLINE><RCDATA><RCDATALINE><TRC>, I need to print out the value of <RCINFO><RCLINE><RCEXPLANATION><LINE> when the <DETAILLINE><RCDATA><RCDATALINE><RC> (1A) matches the
I do preface the <DETAILLINE><RCDATA><RCDATALINE><RC> with "RC " so a match can be found.

NOTE: <DETAILLINE><RCDATA><RCDATALINE> can occur up to six times.

So from the above elements, I only need "This is my explanation line" to be printed once.

I'm using the following code which works when there are values only in the first <DETAILLINE><RCDATA><RCDATALINE>. However, when there are values in more than one of the six occurs, I do not get "This is my explanation line" printed.

  <xsl:sort select="RC" order="ascending"/>			
  <xsl:variable name="varRCDATALINERC" select="RC"/>
  <xsl:variable name="varRCDATALINETRC" select="TRC"/>
  <xsl:variable name="varRCDATA" select="RC"/>
  <xsl:variable name="varRCCODEMatch" select="concat(substring(/doc/EOB/RCINFO/RCLINE[1]/RCCODE,1,3),RC)"/>
  <xsl:if test="RC[.!=''] and TRC[.=36]">					
    <xsl:if test="$varRCCODEMatch=following::*/RCCODE">		
      <xsl:if test="(not($varRCDATALINERC=ancestor-or self::*/preceding::*/RCDATALINE/RC)) and (not($varRCDATALINETRC=ancestor-or-self::*/preceding::*/RCDATALINE/TRC))">
I've been working on this most of the day and am stumped!
Any help will be greatly appreciated.

Thank you,