xsl-list
[Top] [All Lists]

Re: [xsl] Fetch a sequence of nodes from input file

2009-09-23 21:34:31
At 2009-09-23 18:34 -0400, rowan(_at_)sylvester-bradley(_dot_)org wrote:
Thanks very much for these ideas. I'm trying to use Martin's solution but I
don't understand the line:
<xsl:copy-of select="$si | $si/following-sibling::item[. &lt;&lt;
$si/following-sibling::item[level &lt;= $si/level][1]]"/>

What does &lt;&lt; or << mean?

$a << $b is true when the singleton node in the variable "a" is before the singleton node "b" in document order in the same tree.

$a >> $b is true when $a is after $b in document order in the same tree.

$a is $b is true when $a is the same node as $b.

Now I said "in the same tree", but it works it just is implementation dependent when comparing nodes from one tree to another tree. One processor will have it one way and another processor will have it in another order. So you will get true/false when comparing document order between nodes from different trees, but not necessarily the same answer when using two different processors on the same tree.

I hope this helps.

. . . . . . . . . Ken

T:\ftemp>type rowan2.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="2.0">

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:variable name="tree1" as="element(doc)">
    <doc>
      <a/>
      <b/>
    </doc>
  </xsl:variable>
  <xsl:variable name="tree2" as="element(doc)">
    <doc>
      <a/>
      <b/>
    </doc>
  </xsl:variable>

1/a &lt;&lt; 1/b: <xsl:value-of select="$tree1/a &lt;&lt; $tree1/b"/>
1/a >> 1/b: <xsl:value-of select="$tree1/a >> $tree1/b"/>
1/a is 1/a: <xsl:value-of select="$tree1/a is $tree1/a"/>
1/a is 1/b: <xsl:value-of select="$tree1/a is $tree1/b"/>
1/a &lt;&lt; 2/b: <xsl:value-of select="$tree1/a &lt;&lt; $tree2/b"/>
1/a >> 2/b: <xsl:value-of select="$tree1/a >> $tree2/b"/>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>xslt2 rowan2.xsl rowan2.xsl


1/a << 1/b: true
1/a >> 1/b: false
1/a is 1/a: true
1/a is 1/b: false
1/a << 2/b: true
1/a >> 2/b: false
T:\ftemp>



--
Upcoming hands-on code list, UBL, XSLT, XQuery and XSL-FO classes.
Interested in other classes?  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>