xsl-list
[Top] [All Lists]

Re: [xsl] change xslt processing order

2011-10-04 17:22:27
I got your expected results by running your original data and
transform from your very first message modified only by the addition
of the <xsl:if> I described, as follows:

  <xsl:template match="Parcel">
    <xsl:value-of select="@PARCEL_NO"/>
    <xsl:value-of select="$newline"/>
    <xsl:if test="not(following-sibling::*[1][self::Parcel])">
      <xsl:apply-templates select="preceding-sibling::DeliveryAddress[1]"/>
      <xsl:apply-templates select="preceding-sibling::Consignment[1]"/>
    </xsl:if>
  </xsl:template>

On Tue, Oct 4, 2011 at 3:16 PM, Navin Patel <navin98(_at_)gmail(_dot_)com> 
wrote:
Brandon,

Thanks for your suggestion, but I do want to output the
DeliveryAddress and Consignment after a Parcel even if one parcel
follows another its just that I want output the DeliveryAddress and
Consignment after the last parcel in a group of parcels i.e.

If a Parcel, "4", is immediately followed by another Parcel, "5", then
Parcel "4" isn't the last in the group, right?

The above test breaks down like this:
1. Select all following sibling nodes that are elements. (following-sibling::*)
2. Of these, select just the first in document order. ([1])
3. Discard this unless it is a Parcel. ([self::Parcel])
4. Return true if there are no nodes left. (not())

-Brandon :)


Expected out:
JD0002210800004322
7255
044375530
JD0002210800004323
7256
044375531
JD0002210800004324
JD0002210800004325
7257
044375532

With the suggestion below I don't get any output for the
DeliveryAddress and Consignment for the last two parcels in the XML.

The "test" on the <xsl:if> would be
"not(following-sibling::*[1][self::Parcel])".  This would output the
DeliveryAddress and Consignment after a Parcel only if it was not
immediately followed by another Parcel.

JD0002210800004322
7255
 044375530
JD0002210800004323
7256
044375531
JD0002210800004324
JD0002210800004325

Thanks

Navin

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>