<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/book.cmark.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'class.commonmark-cql.php',
    1 => 'CommonMark\\CQL',
    2 => 'The CommonMark\\CQL class',
  ),
  'up' => 
  array (
    0 => 'book.cmark.php',
    1 => 'CommonMark',
  ),
  'prev' => 
  array (
    0 => 'commonmark-parser.finish.php',
    1 => 'CommonMark\\Parser::finish',
  ),
  'next' => 
  array (
    0 => 'commonmark-cql.construct.php',
    1 => 'CommonMark\\CQL::__construct',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/cmark/commonmark.cql.xml',
  ),
  'history' => 
  array (
  ),
  'extra_header_links' => 
  array (
    'rel' => 'alternate',
    'href' => '/manual/en/feeds/class.commonmark-cql.atom',
    'type' => 'application/atom+xml',
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="class.commonmark-cql" class="reference">

 <h1 class="title">The CommonMark\CQL class</h1>
 

 <div class="partintro"><p class="verinfo">(cmark &gt;= 1.1.0)</p>


  <div class="section" id="commonmark-cql.intro">
   <h2 class="title">Introduzione</h2>
   <p class="simpara">
    CommonMark Query Language is a DSL for describing how to travel through a CommonMark Node tree implemented as a parser and compiler for a small set of instructions, and a virtual machine for executing those instructions.
   </p>
   <p class="formalpara">
    <h5 class="title">Paths:</h5>
     <p class="para">
      In it&#039;s most simplistic form, a CQL query combines the following paths and <code class="literal">/</code> to describe how to travel through a tree:
      <ul class="simplelist">
       <li>firstChild</li>
       <li>lastChild</li>
       <li>previous</li>
       <li>next</li>
       <li>parent</li>
      </ul>
      For example, <code class="literal">/firstChild/lastChild</code> would travel to the last child node of the first child node.
     </p>
   </p>
   <p class="formalpara">
   <h5 class="title">Loops</h5>
   <p class="para">
    CQL can be instructed to loop, for example through the children of, or siblings to a particular node, by using the path <code class="literal">children</code>, or <code class="literal">siblings</code>. For example, <code class="literal">/firstChild/children</code> will travel to all the children of the first child node.
   </p>
   </p>
   <p class="formalpara">
    <h5 class="title">Subqueries</h5>
     <p class="para">
      CQL can be instructed how to travel by using a subquery like <code class="literal">[/firstChild]</code>. For example, <code class="literal">/firstChild/children[/firstChild]</code> will travel to the first child node of all the children of the first child node.
     </p>
   </p>
   <p class="formalpara">
    <h5 class="title">Loop Constraints</h5>
     <p class="para">
      While looping, CQL can be instructed to constrict the travelled path to nodes of particular type. For example <code class="literal">/children(BlockQuote)</code> will travel to the children of a node where the type is <code class="literal">BlockQuote</code>. The following types are recognized (case insensitively):
      <ul class="simplelist">
       <li>BlockQuote</li>
       <li>List</li>
       <li>Item</li>
       <li>CodeBlock</li>
       <li>HtmlBlock</li>
       <li>CustomBlock</li>
       <li>Paragraph</li>
       <li>Heading</li>
       <li>ThematicBreak</li>
       <li>Text</li>
       <li>SoftBreak</li>
       <li>LineBreak</li>
       <li>Code</li>
       <li>HtmlInline</li>
       <li>CustomInline</li>
       <li>Emphasis</li>
       <li>Strong</li>
       <li>Link</li>
       <li>Image</li>
      </ul>
      Types may be used as a union, for example <code class="literal">/children(BlockQuote|List)</code> will travel to the children of a node where the type is <code class="literal">BlockQuote</code> or <code class="literal">List</code>. Types, or unions of types, may be also negated. For example <code class="literal">/children(~BlockQuote)</code> will travel to the children of a node where the type is not <code class="literal">BlockQuote</code>, and <code class="literal">/children(~BlockQuote|Paragraph)</code> will travel to the children of a node where the type is not <code class="literal">BlockQuote</code> or <code class="literal">Paragraph</code>
     </p>
   </p>
   <p class="formalpara">
    <h5 class="title">Path Constraints</h5>
     <p class="para">
      CQL can be instructed to create a loop to travel to a node of a particular type, at a particular path. For example, <code class="literal">/firstChild(BlockQuote)</code> will travel to the first child node where the type is <code class="literal">BlockQuote</code>. Note that like other loops for <code class="literal">children</code> and <code class="literal">siblings</code>, this kind of path can only be followed by a subquery.
     </p>
   </p>
   <p class="formalpara">
    <h5 class="title">Implementation Notes</h5>
    <p class="para">
    While CQL has been implemented as part of the PHP CommonMark extension, it stands separately from PHP and does not use PHP&#039;s virtual machine or internal representation of values.
   </p>
   </p>
  </div>


  <div class="section" id="commonmark-cql.synopsis">
   <h2 class="title">Sommario della classe</h2>


   <div class="classsynopsis">
    <span class="ooclass"><strong class="classname"></strong></span>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">class</span> <strong class="classname">CommonMark\CQL</strong>
     </span>
     {</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Constructor */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="commonmark-cql.construct.php" class="methodname">__construct</a></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$query</code></span>)</div>


    <div class="classsynopsisinfo classsynopsisinfo_comment">/* Metodi */</div>
    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="commonmark-cql.invoke.php" class="methodname">__invoke</a></span>(<span class="methodparam"><span class="type"><a href="class.commonmark-node.php" class="type CommonMark\Node">CommonMark\Node</a></span> <code class="parameter">$root</code></span>, <span class="methodparam"><span class="type"><a href="language.types.callable.php" class="type callable">callable</a></span> <code class="parameter">$handler</code></span>)</div>

   }</div>


  </div>

 </div>

  




  





<h2>Indice dei contenuti</h2><ul class="chunklist chunklist_reference"><li><a href="commonmark-cql.construct.php">CommonMark\CQL::__construct</a> — CQL Construction</li><li><a href="commonmark-cql.invoke.php">CommonMark\CQL::__invoke</a> — CQL Execution</li></ul>
</div>
<?php manual_footer($setup); ?>