[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

using Xpath predicate to filter source nodes in called

Subject: using Xpath predicate to filter source nodes in called templates
From: "Chris Pearson" <chrisp@xxxxxxxxxxx>
Date: Fri, 11 Jan 2002 13:25:57 -0500
xsl xpath filter
Hello list,

I have an xml source with 3 hierarchical levels. (anyone familiar with EDI will recognize element names...)  However, within this structure, there are implied loops.  An <ISA> element is closed by an <IEA> element, a <GS> element is closed by a <GE> element, a <ST> element is closed by an <SE> element.  Within the <ST> the <LIN> may loop repeatedly, and within the <LIN> the <FST> may loop repeatedly.

I'm trying the following, but I'm getting ALL LINs/FSTs for the first, then all but the first LINs/FSTs for the second, then all but the first and second LINs/FSTs for the third and so on..  Anyone got any suggestions?

Thanks,
Chris

The XSLT is:
<xsl:template name="ST">
<xsl:param name="param1"/>
<xsl:for-each select="../ST[preceding-sibling::GS/GS1=$param1]">
  <!-- write the elements associated with the ST before calling LIN template-->
  <xsl:call-template name="LIN">
    <xsl:with-param name="param2" select="ST/ST1"/>
  </xsl:call-template>
</xsl:for-each>
</xsl:template>

<xsl:template name="LIN">
<xsl:param name="param1"/>
<xsl:param name="param2"/>
<xsl:for-each select="../LIN[preceding-sibling::ST/ST1=$param1]">
  <!-- write the elements associated with the LIN before calling FST template-->
  <xsl:call-template name="FST">
    <xsl:with-param name="param3" select="LIN/LIN1"/>
  </xsl:call-template>
</xsl:for-each>
</xsl:template>

<xsl:template name="FST">
<xsl:param name="param1"/>
<xsl:param name="param2"/>
<xsl:param name="param3"/>
<xsl:for-each select="../FST[preceding-sibling::LIN/LIN1=$param2][preceding-sibling::ST/ST1=$param1]">
  .. do stuff for each FST element ..
</xsl:for-each>
</xsl:template>

The XML structure:
<root>
  <ISA>
    <ISA1 />
    <ISAn />
  </ISA>
  <GS>
    <GS1 />
    <GSn />
  </GS>
  <ST>
    <ST1 />
    <STn />
  </ST>
  <LIN> <!-- May repeat within ST elements-->
    <LIN1 />
    <LINn />
  </LIN>
  <FST> <!-- May repeat within LIN elements -->
    <FST1 /
    <FSTn />
  </FST>
  <SHP>
    <SHP1 />
    <SHPn />
  </SHP>
  <SE>
    <SE1 />
    <SEn />
  <GE>
    <GE1 />
    <GEn />
  </GE>
 <IEA>
    <IEA1 />
    <IEAn />
  </IEA>  
</root>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.