Hello good people,

Thank you Andreas, J.Pietschmann, and Riz for helping me out.  Your
suggestions got me started on the right track.  For your edification, here
is what I came up with that works:

<xsl:for-each select="MUInventory/Category"> <!-- Outer Loop -->
  <xsl:variable name="lastCat"><xsl:value-of select="
normalize-space(preceding-sibling::node()[2]/id)"/></xsl:variable>
  <xsl:variable name="lastType"><xsl:value-of select="
normalize-space(preceding-sibling::node()[2]/Type)"/></xsl:variable>
     <xsl:if test="concat(id,Type) != concat($lastCat,$lastType)">
       <fo:table-row span="all">
          <fo:table-cell width="3in">
            <fo:block>
               <xsl:value-of select="concat(./id,' - ', ./Type)"/>  <!--
last = <xsl:value-of select="$lastCat"/>  -  <xsl:value-of
select="$lastType"/>
                 Current NODE: <xsl:value-of select="./node"/> and
Preceding NODE: <xsl:value-of select="preceding-sibling::node()[2]/node"/>
-->
            </fo:block>
          </fo:table-cell>
       </fo:table-row>
     </xsl:if>

     ...next

First, I got rid of the text nodes just to minimize ambiguous behaviors.
Then I went about testing your suggestions and found that when using
<xsl:if test="self::node()[not(id=preceding-sibling::node()[2]/id)] and
self::node()[not(Type=preceding-sibling::node()[2]/Type)]"> instead of <
xsl:if test="concat(id,Type) != concat($lastCat,$lastType)">, it would
evaluate true for the first node and the last node and give me a header for
Motorcycles - Cruisers   and   Motorcycles - Standard, leaving out the
others.  I had to use [2] instead of [1] in the path to get the correct
node.  I have no solid reason as to why, but maybe it's the manner in which
the nodes are being numbered internally on the object stack.  As you can
see, I had troubleshooting code in the output.  If I used the expressions
self::node()[not(id=preceding-sibling::node()[2]/id)] and
self::node()[not(Type=preceding-sibling::node()[2]/Type)] on separate
<xsl:if...> statements, it still would exibit the same same wrong behavior
as witnessed when chaining them together with boolean logic.  So much for
elegance, I concatenated and made a direct comparism and viola`, it now
gives me the table below:

My XML file will always be in category order, so there is no sorting or
other problem areas to anticipate.

Motorcycles - Cruisers
2001 Harley Davidson XL1200 Sportster
2002 Harley Davidson 883 Sportster
2003 Honda VT750 Shadow Spirit
2000 Yamaha Royal Star Venture
2002 Yamaha V Star 650 Custom
2004 Yamaha V Star 650 Silverado Classic
2004 Yamaha V Star 650 Classic
2005 Yamaha Royal Star Tour Deluxe
Motorcycles - Off-Road
2002 Suzuki DR200
Motorcycles - Scooters
2003 Aprilia Rally 50
2003 Aprilia SR 50
Motorcycles - Sport
2004 Suzuki Katana 600
ATV - Sport
2001 Yamaha Banshee
Motorcycles - Standard
2004 Suzuki SV650


Thanks again!

Curtis Fisher






> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]

Hi,

> I am attempting to compare the values in one node with the preceding
node.
> When using the preceding-sibling on the first node, it retuns a
> null (which is good), but thereafter returns the value of the first
> node (only) as the tree is processed.

Not completely sure, but the problem might be that:

preceding-sibling::node()

returns the first node on the preceding-sibling axis, but 'first' here
being
'in document order'... (as in: take the set of all preceding-siblings and
of
that set, return the one that appears first in the source document)

> If I use the axisName following:: or following-sibling:: then it works
fine.

Yes, because here the immediately following (sibling) node is always also
first one following in the document as well.

Try:

self::node()[not(text()=preceding-sibling::node()[1]/text())]

IIC, the addition of '[1]' should make sure you return the immediately
preceding-sibling.

HTH!

Greetz,

Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to