[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?


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: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: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 ..

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

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

Current Thread


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.
First Name
Last Name
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.