Re: [xsl] Using operators >> and <<

Subject: Re: [xsl] Using operators >> and <<
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 12 Jan 2009 20:16:26 -0500
At 2009-01-12 17:59 -0600, Ylvisaker, Steve wrote:
I need to take the following markup:
And turn it into:
It is easy enough to identify and format the <ulist/> based on the occurrence of the first <bullet/> but then isolating just the remaining contiguous bullets eludes me.

I approached it differently: finding the adjacent groups that are or are not made up entirely of bullets.

I have the feeling that I can use the << or >> operators to select all of the bullets until the node name changes in the document order.

I don't think so, because they'll look past the first of the groups.

However, I can only find very sketchy documentation regarding these constructs and when I try to use them I get syntax errors.

Remember you cannot have naked "<" characters in attribute specifications ... you need to escape them.

Any suggestions or pointers on where I could look for working examples (not shorthand) of how these constructs can be used or suggestions on a different approach would be very much appreciated.

How about a different approach, then ... I hope the code below helps. Note how I am calculating a value for every member of the population being grouped by adjacent equal values, and the value I'm calculating is either true or false for each member. Any value calculated for a member of the population can be used when grouping.

. . . . . . . Ken

t:\ftemp>type steve.xml
<para>a para of data</para>
<bullet>first bullet data</bullet>
<bullet>second bullet data</bullet>
<bullet>third bullet data</bullet>
<para>more para data</para>
<bullet>another bullet list</bullet>

t:\ftemp>call xslt2 steve.xml steve.xsl
<?xml version="1.0" encoding="UTF-8"?>
<para>a para of data</para>
      <para>first bullet data</para>
      <para>second bullet data</para>
      <para>third bullet data</para>
<para>more para data</para>
      <para>another bullet list</para>
t:\ftemp>type steve.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="";

<xsl:output indent="yes"/>

<xsl:template match="steve">
  <!--find all adjacent groups that are or not made up of bullets-->
  <xsl:for-each-group select="*" group-adjacent="boolean(self::bullet)">
      <xsl:when test="self::bullet">
        <!--here is an adjacent group that is made up of bullets-->
          <xsl:for-each select="current-group()">
        <!--here is an adjacent group that is not made up of bullets-->
        <xsl:apply-templates select="current-group()"/>

<xsl:template match="@*|node()"><!--identity for all other nodes-->
    <xsl:apply-templates select="@*|node()"/>


Upcoming XSLT/XSL-FO, UBL and code list hands-on training classes:
:  Sydney, AU 2009-01/02; Brussels, BE 2009-03; Prague, CZ 2009-03
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread