2013-04-11 63 views
0
CASE 1: 

<Loop type="MAIN01" name="MAIN01 Data"> 
      <RepeatingSegment type="MAIN01" name="MAIN REP SEG"> 
      <Segment type="MAIN01" name="MAIN SEG"> 
       <Element type="350" name="Element_Of_Main01" param=" ">1</Element> 
      </Segment> 
      </RepeatingSegment> 
      <Loop type="POOT" name="POOT Data"> 
      <RepeatingSegment type="POOT" name="POOT REP SEG"> 
      <Segment type="POOT" name="POOT SEG"> 
       <Element type="349" name="Element_Of_POOT" dt="I" param=" ">F</Element> 
      </Segment> 
      </RepeatingSegment> 
      </Loop> 
      <Loop type="SAC" name="Service, Promotion, Allowance, or Charge Information"> 
      <RepeatingSegment type="SAC" name="Service, Promotion, Allowance, or Charge Information - REP SEG"> 
      <Segment type="SAC" name="Service, Promotion, Allowance, or Charge Information"> 
       <Element type="248" name="Allowance or Charge Indicator" dt="I" >C</Element> 
       </Segment> 
      </RepeatingSegment> 
      </Loop> 
</Loop>    


CASE 2: 
    <Loop type="MAIN01" name="MAIN01 Data"> 
      <RepeatingSegment type="MAIN01" name="MAIN REP SEG"> 
      <Segment type="MAIN01" name="MAIN SEG"> 
       <Element type="350" name="Element_Of_Main01" param=" ">1</Element> 
      </Segment> 
      </RepeatingSegment> 
      <Loop type="POOT" name="POOT Data"> 
      <RepeatingSegment type="POOT" name="POOT REP SEG"> 
      <Segment type="POOT" name="POOT SEG"> 
       <Element type="349" name="Element_Of_POOT" dt="I" param=" ">F</Element> 
      </Segment> 
      </RepeatingSegment> 
      </Loop> 
</Loop>  

情景,我想萬一1與之前的「POOT」萬一「SAC」前插入一張圖片2.XSLT邏輯順序 - 配售圖像

當前現有的邏輯只是outter環MAIN01去,在段類型=「MAIN_01」的末尾插入圖像。這意味着圖像在情況1中的「POOT」之前顯得非常好。

<xsl:if test="(ancestor::Loop[1]/@type = 'MAIN01' or ancestor::Loop[2]/@type = 'MAIN01') and (ancestor::RepeatingSegment/following-sibling::Loop or ancestor::RepeatingSegment[1]/following-sibling::RepeatingSegment[1]/@type != 'MAIN01')"> 
    IMAGE ADDED HERE !! 
</xsl:if>  


Expected: 
     case 1: 
      MAIN01 -> POOT -> IMAGE --> SAC 
     case 2: 
      MAIN01 ->IMAGE --> POOT 


Current status : 
     case 1: 
      MAIN01 -> IMAGE --> POOT -> SAC 
     case 2: 
      MAIN01 -> IMAGE --> POOT 

在此先感謝您。任何建議表示讚賞。

回答

0

看起來像是喜歡在最後一個Loop元素之前有一個圖像,它是Loop元素的子元素。

<xsl:template match="Loop"> 
    <xsl:if test="parent::Loop 
      and (
      generate-id(parent::Loop/Loop[last()]) 
      = 
      generate-id(.))"> 

    -- image-- 
    </xsl:if> 
    <xsl:apply-templates /> 
</xsl:template>