Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 3087

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xsl-elements" page="for-each-group" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: xsl:for-each-group</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: xsl:for-each-group"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>xsl:for-each-group</h1>
      <p>The <code>xsl:for-each-group</code> element selects a sequence of nodes and/or atomic
values and organizes them into subsets called groups. There are four possible ways of defining the
grouping:</p>
      <ul>
         <li content="para">
            <p>
            <b>group-by:</b> This groups together all items having the same value for a grouping key.
The grouping key may have multiple values (a sequence of values) in which case the item is added
to more than one group.</p>
         </li>
         <li content="para">
            <p>
            <b>group-adjacent:</b> This groups together all items having the same value for a grouping key,
provided that they are also adjacent in the input sequence. This is useful when you need to wrap a
new element around a sequence of related elements in the source documents, for example a consecutive
sequence of <code>&lt;bullet&gt;</code> elements. In this case the grouping key must be single-valued.</p>
         </li>
         <li content="para">
            <p>
            <b>group-starting-with:</b> This processes the items in the supplied sequence in turn, starting
a new group whenever one of the items matches a specified pattern. This is useful, for example,
when matching an <code>&lt;h2&gt;</code> element and its following <code>&lt;p&gt;</code>
elements.</p>
         </li>
         <li content="para">
            <p>
            <b>group-ending-with:</b> This processes the items in the supplied sequence in turn, closing
the current group whenever one of the items matches a specified pattern. This is useful
when matching a sequence of items in which the last item in the group carries some distinguishing
attribute such as <code>continued="no"</code>.</p>
         </li>
      </ul>
      <p>Saxon implements the <code>xsl:for-each-group</code> instruction in full. 
            For examples of using the instruction, see 
<a href="http://www.w3.org/TR/xslt20/#grouping" class="bodylink">the XSLT 2.0 specification</a>.</p>
      <p>In XSLT 3.0, the capabilities of the <code>xsl:for-each-group</code> instruction
         are extended by virtue of the fact that the pattern used in <code>group-starting-with</code>
         or <code>group-ending-with</code> can now match atomic values as well as nodes.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="function.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>