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中的“SAC”之前和案例2中的“POOT”之前插入PICTURE。
当前现有的逻辑只是通过外循环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 :(得分: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>