The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

Name

Data::Edit::Xml - Edit data held in the XML format.

Synopsis

Create a new XML parse tree:

  my $a = Data::Edit::Xml::new q(<a><b><c/></b><d><c/></d></a>);

use:

  say STDERR -p $a;

to print:

  <a>
    <b>
      <c/>
    </b>
    <d>
      <c/>
    </d>
  </a>

Cut out c under b but not under d in the created tree by traversing in post-order applying a sub to each node to cut out c when we are at c under b under a.

  $a -> by(sub {$_ -> cut_c_b_a});

Or if you know when you are going:

  $a -> go_b_c__cut;

To get:

  <a>
    <b/>
    <d>
      <c/>
    </d>
  </a>

Location of nodes in source content

Locate nodes in the source content by parsing the source retaining line numbers:

  my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1);
<a>
 <b>
  <c/>
  <c>
    <d/>
  </c>
 </b>
</a>
END

then locating nodes:

  ok $a->go_b_c_1_d__location eq q( on line 5 from 5 to 8);

Bullets to unordered list

To transform a series of bullets into <ul><li>...</li></ul>, parse the input XML:

  my $a = Data::Edit::Xml::new(<<END);
<a>
<p>• Minimum 1 number</p>
<p>•   No leading, trailing, or embedded spaces</p>
<p>• Not case-sensitive</p>
</a>
END

Traverse the resulting parse tree, removing bullets and changing <p> to <li>, <a> to <ul>:

  $a->change_ul->by(sub
   {$_->up__change_li if $_->text_p and $_->text =~ s/\A•\s*//s
   });

Print to get:

  ok -p $a eq <<END;
<ul>
  <li>Minimum 1 number</li>
  <li>No leading, trailing, or embedded spaces</li>
  <li>Not case-sensitive</li>
</ul>
END

DocBook to Dita

To transform some DocBook XML into Dita:

  use Data::Edit::Xml;

  # Parse the DocBook XML

  my $a = Data::Edit::Xml::new(<<END);
<sli>
  <li>
    <p>Diagnose the problem</p>
    <p>This can be quite difficult</p>
    <p>Sometimes impossible</p>
  </li>
  <li>
  <p><pre>ls -la</pre></p>
  <p><pre>
drwxr-xr-x  2 phil phil   4096 Jun 15  2016 Desktop
drwxr-xr-x  2 phil phil   4096 Nov  9 20:26 Downloads
</pre></p>
  </li>
</sli>
END

  # Transform to Dita step 1

  $a->by(sub
   {my ($o, $p) = @_;
    if ($o->at(qw(pre p li sli)) and $o->isOnlyChild)
     {$o->change($p->isFirst ? qw(cmd) : qw(stepresult));
      $p->unwrap;
     }
    elsif ($o->at(qw(li sli))    and $o->over(qr(\Ap( p)+\Z)))
     {$_->change($_->isFirst ? qw(cmd) : qw(info)) for $o->contents;
     }
   });

  # Transform to Dita step 2

  $a->by(sub
  {my ($o) = @_;
   $o->change(qw(step))          if $o->at(qw(li sli));
   $o->change(qw(steps))         if $o->at(qw(sli));
   $o->id = 's'.($o->position+1) if $o->at(qw(step));
   $o->id = 'i'.($o->index+1)    if $o->at(qw(info));
   $o->wrapWith(qw(screen))      if $o->at(qw(CDATA stepresult));
  });

  # Print the results

  say STDERR -p $a;

Produces:

  <steps>
    <step id="s1" otherprops="s1">
      <cmd>Diagnose the problem
      </cmd>
      <info id="i1" otherprops="i1">This can be quite difficult
      </info>
      <info id="i2" otherprops="i2">Sometimes impossible
      </info>
    </step>
    <step id="s2" otherprops="s2">
      <cmd>ls -la
      </cmd>
      <stepresult>
        <screen>
  drwxr-xr-x  2 phil phil   4096 Jun 15  2016 Desktop
  drwxr-xr-x  2 phil phil   4096 Nov  9 20:26 Downloads
        </screen>
      </stepresult>
    </step>
  </steps>

Description

Edit data held in the XML format.

Version 20190121.

The following sections describe the methods in each functional area of this module. For an alphabetic listing of all methods by name see Index.

Immediately useful methods

These methods are the ones most likely to be of immediate use to anyone using this module for the first time:

at

Confirm that the specified $node has the specified ancestry and return the specified $node if it does else undef. Ancestry is specified by providing the expected tags that the $node's parent, the parent's parent etc. must match at each level. If undef is specified then any tag is assumed to match at that level. If a regular expression is specified then the current parent node tag must match the regular expression at that level. If all supplied tags match successfully then the starting node is returned else undef

attr

Return the value of an attribute of the current node as an lvalue sub.

attrX

Return the value of the specified $attribute of the specified $node or q() if the $node does not have such an attribute.

by

Post-order traversal of a parse tree or sub tree calling the specified sub at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. A reference to the current node is also made available via $_. This is equivalent to the x= operator.

change

Change the name of the specified $node, optionally confirming that the $node is in a specified context and return the $node.

cut

Cut out the specified $node so that it can be reinserted else where in the parse tree.

go

Return the node reached from the specified $node via the specified path: (index position?)* where index is the tag of the next node to be chosen and position is the optional zero based position within the index of those tags under the current node. Position defaults to zero if not specified. Position can also be negative to index back from the top of the index array. * can be used as the last position to retrieve all nodes with the final tag.

new

Create a new parse tree - call this method statically as in Data::Edit::Xml::new(file or string) to parse a file or string or with no parameters and then use "input", "inputFile", "inputString", "errorFile" to provide specific parameters for the parse, then call "parse" to perform the parse and return the parse tree.

prettyString

Return a readable string representing a node of a parse tree and all the nodes below it. Or use -p $node

putLast

Place a cut out or new node last in the content of the specified $node and return the new node. See addLast to perform this operation conditionally.

unwrap

Unwrap the specified $node by inserting its content into its parent at the point containing the specified $node and return the parent node. Returns undef if an attempt is made to unwrap a text node. Confesses if an attempt is made to unwrap the root node.

wrapWith

Wrap the specified $node in a new node created from the specified $tag and %attributes forcing the specified $node down - deepening the parse tree - return the new wrapping node. See addWrapWith to perform this operation conditionally.

Construction

Create a parse tree, either by parsing a file or string, or, node by node, or, from another parse tree.

File or String

Construct a parse tree from a file or a string.

new($@)

Create a new parse tree - call this method statically as in Data::Edit::Xml::new(file or string) to parse a file or string or with no parameters and then use "input", "inputFile", "inputString", "errorFile" to provide specific parameters for the parse, then call "parse" to perform the parse and return the parse tree.

     Parameter          Description
  1  $fileNameOrString  Optional file name or string from which to construct the parse tree
  2  @options           Hash of other options.

Example:

   {my $a = Data::Edit::Xml::𝗻𝗲𝘄(<<END);
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

This is a static method and so should be invoked as:

  Data::Edit::Xml::new

cdata()

The name of the tag to be used to represent text - this tag must not also be used as a command tag otherwise the parser will confess.

Example:

   {ok Data::Edit::Xml::𝗰𝗱𝗮𝘁𝗮 eq q(CDATA);

parse($)

Parse input XML specified via: inputFile, input or inputString.

     Parameter  Description
  1  $parser    Parser created by L</new>

Example:

   {my $x = Data::Edit::Xml::new;

       $x->inputString = <<END;
  <a id="aa"><b id="bb"><c id="cc"/></b></a>
  END

       $x->𝗽𝗮𝗿𝘀𝗲;

       ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
  </a>
  END

Node by Node

Construct a parse tree node by node.

newText($$)

Create a new text node.

     Parameter  Description
  1  undef      Any reference to this package
  2  $text      Content of new text node

Example:

    ok -p $x eq <<END;
  <a class="aa" id="1">
    <b class="bb" id="2"/>
  </a>
  END

    $x->putLast($x->𝗻𝗲𝘄𝗧𝗲𝘅𝘁("t"));

    ok -p $x eq <<END;
  <a class="aa" id="1">
    <b class="bb" id="2"/>
  t
  </a>
  END

newTag($$%)

Create a new non text node.

     Parameter    Description
  1  undef        Any reference to this package
  2  $command     The tag for the node
  3  %attributes  Attributes as a hash.

Example:

   {my $x = Data::Edit::Xml::newTree("a", id=>1, class=>"aa");

    $x->putLast($x->𝗻𝗲𝘄𝗧𝗮𝗴("b", id=>2, class=>"bb"));

    ok -p $x eq <<END;
  <a class="aa" id="1">
    <b class="bb" id="2"/>
  </a>
  END

newTree($%)

Create a new tree.

     Parameter    Description
  1  $command     The name of the root node in the tree
  2  %attributes  Attributes of the root node in the tree as a hash.

Example:

   {my $x = Data::Edit::Xml::𝗻𝗲𝘄𝗧𝗿𝗲𝗲("a", id=>1, class=>"aa");

    ok -s $x eq '<a class="aa" id="1"/>';

replaceSpecialChars($)

Replace < > " & with &lt; &gt; &quot; &amp; Larry Wall's excellent Xml parser unfortunately replaces &lt; &gt; &quot; &amp; etc. with their expansions in text by default and does not seem to provide an obvious way to stop this behavior, so we have to put them back again using this method.

     Parameter  Description
  1  $string    String to be edited.

Example:

    ok Data::Edit::Xml::𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗦𝗽𝗲𝗰𝗶𝗮𝗹𝗖𝗵𝗮𝗿𝘀(q(<">)) eq q(&lt;&quot;&gt;);

This is a static method and so should be invoked as:

  Data::Edit::Xml::replaceSpecialChars

undoSpecialChars($)

Reverse the results of calling replaceSpecialChars.

     Parameter  Description
  1  $string    String to be edited.

Example:

    ok Data::Edit::Xml::𝘂𝗻𝗱𝗼𝗦𝗽𝗲𝗰𝗶𝗮𝗹𝗖𝗵𝗮𝗿𝘀(q(&lt;&quot;&gt;)) eq q(<">);

This is a static method and so should be invoked as:

  Data::Edit::Xml::undoSpecialChars

Parse tree attributes

Attributes of a node in a parse tree. For instance the attributes associated with an XML tag are held in the attributes attribute. It should not be necessary to use these attributes directly unless you are writing an extension to this module. Otherwise you should probably use the methods documented in other sections to manipulate the parse tree as they offer a safer interface at a higher level.

Parse tree

Construct a parse tree from another parse tree.

renew($@)

Returns a renewed copy of the parse tree, optionally checking that the starting node is in a specified context: use this method if you have added nodes via the "Put as text" methods and wish to traverse their parse tree.

Returns the starting node of the new parse tree or undef if the optional context constraint was supplied but not satisfied.

     Parameter  Description
  1  $node      Node to renew from
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new("<a/>");

    $a->putFirstAsText(qq(<b/>));

    ok !$a->go(q(b));

    my $A = $a->𝗿𝗲𝗻𝗲𝘄;

    ok -t $A->go(q(b)) eq q(b)

clone($@)

Return a clone of the parse tree optionally checking that the starting node is in a specified context: the parse tree is cloned without converting it to string and reparsing it so this method will not renew any nodes added as text.

Returns the starting node of the new parse tree or undef if the optional context constraint was supplied but not satisfied.

     Parameter  Description
  1  $node      Node to clone from
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new("<a> </a>");

    my $A = $a->𝗰𝗹𝗼𝗻𝗲;

    ok -s $A eq q(<a/>);

    ok $a->equals($A);

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a>aaa
      <b>bbb</b>
      ccc
      <d>ddd</d>
      eee
    </a>
  </x>
  END

    my $y = $x->𝗰𝗹𝗼𝗻𝗲;

    ok !$x->diff($y);

equals($$)

Return the first node if the two parse trees have identical representations via string, else undef.

     Parameter  Description
  1  $node1     Parse tree 1
  2  $node2     Parse tree 2.

Example:

   {my $a = Data::Edit::Xml::new("<a> </a>");

    my $A = $a->clone;

    ok -s $A eq q(<a/>);

    ok $a->𝗲𝗾𝘂𝗮𝗹𝘀($A);

equalsIgnoringAttributes($$@)

Return the first node if the two parse trees have identical representations via string if the specified attributes are ignored, else undef.

     Parameter    Description
  1  $node1       Parse tree 1
  2  $node2       Parse tree 2
  3  @attributes  Attributes to ignore during comparison

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b   id="1" outputclass="1" name="b">
      <c id="2" outputclass="2" name="c"/>
    </b>
  </a>
  END

    my $A = Data::Edit::Xml::new(<<END);
  <a>
    <b   id="11" outputclass="11" name="b">
      <c id="22" outputclass="22" name="c"/>
    </b>
  </a>
  END

    ok !$a->equals($A);

    ok !$a->𝗲𝗾𝘂𝗮𝗹𝘀𝗜𝗴𝗻𝗼𝗿𝗶𝗻𝗴𝗔𝘁𝘁𝗿𝗶𝗯𝘂𝘁𝗲𝘀($A, qw(id));

    ok  $a->𝗲𝗾𝘂𝗮𝗹𝘀𝗜𝗴𝗻𝗼𝗿𝗶𝗻𝗴𝗔𝘁𝘁𝗿𝗶𝗯𝘂𝘁𝗲𝘀($A, qw(id outputclass));

diff($$$)

Return () if the dense string representations of the two nodes are equal, else up to the first N (default 16) characters of the common prefix before the point of divergence and the remainder of the string representation of each node from the point of divergence. All <!-- ... --> comments are ignored during this comparison and all spans of white space are reduced to a single blank.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  $N         Maximum length of difference strings to return

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a>aaa
      <b>bbb</b>
      ccc
      <d>ddd</d>
      eee
    </a>
  </x>
  END

    ok !$x->𝗱𝗶𝗳𝗳($x);

    my $y = $x->clone;

    ok !$x->𝗱𝗶𝗳𝗳($y);

    $y->first->putLast($x->newTag(q(f)));

    ok nws(<<END) eq nws(-p $y);
  <x>
    <a>aaa
      <b>bbb</b>
      ccc
      <d>ddd</d>
      eee
      <f/>
    </a>
  </x>
  END

    is_deeply [$x->𝗱𝗶𝗳𝗳($y)],    ["<d>ddd</d> eee <", "/a></x>", "f/></a></x>"];

    is_deeply [𝗱𝗶𝗳𝗳(-p $x, $y)], ["<d>ddd</d> eee <", "/a></x>", "f/></a></x>"];

    is_deeply [$x->𝗱𝗶𝗳𝗳(-p $y)], ["<d>ddd</d> eee <", "/a></x>", "f/></a></x>"];

    my $X = writeFile(undef, -p $x);

    my $Y = writeFile(undef, -p $y);

    is_deeply [𝗱𝗶𝗳𝗳($X, $Y)],    ["<d>ddd</d> eee <", "/a></x>", "f/></a></x>"];

save($$)

Save a copy of the parse tree to a file which can be restored and return the saved node. This method uses Storable which is fast but produces large files that do not compress well. Use writeCompressedFile to produce smaller save files at the cost of more time.

     Parameter  Description
  1  $node      Parse tree
  2  $file      File.

Example:

      $y->𝘀𝗮𝘃𝗲($f);

      my $Y = Data::Edit::Xml::restore($f);

      ok $Y->equals($y);

restore($)

Return a parse tree from a copy saved in a file by save.

     Parameter  Description
  1  $file      File

Example:

      $y->save($f);

      my $Y = Data::Edit::Xml::𝗿𝗲𝘀𝘁𝗼𝗿𝗲($f);

      ok $Y->equals($y);

This is a static method and so should be invoked as:

  Data::Edit::Xml::restore

expandIncludes($)

Expand the includes mentioned in a parse tree: any tag that ends in include is assumed to be an include directive. The file to be included is named on the href keyword. If the file to be included is a relative file name, i.e. it does not begin with / then this file is made absolute relative to the file from which this parse tree was obtained.

     Parameter  Description
  1  $x         Parse tree

Example:

   {my @files =

     (writeFile("in1/a.xml", q(<a id="a"><include href="../in2/b.xml"/></a>)),

      writeFile("in2/b.xml", q(<b id="b"><include href="c.xml"/></b>)),

      writeFile("in2/c.xml", q(<c id="c"/>)));

    my $x = Data::Edit::Xml::new(fpf(currentDirectory, $files[0]));

       $x->𝗲𝘅𝗽𝗮𝗻𝗱𝗜𝗻𝗰𝗹𝘂𝗱𝗲𝘀;

    ok <<END eq -p $x;
  <a id="a">
    <b id="b">
      <c id="c"/>
    </b>
  </a>
  END

Print

Create a string representation of the parse tree with optional selection of nodes via conditions.

Normally use the methods in Pretty to format the XML in a readable yet reparseable manner; use Dense string to format the XML densely in a reparseable manner; use the other methods to produce unreparseable strings conveniently formatted to assist various specialized operations such as debugging CDATA, using labels or creating tests. A number of the file test operators can also be conveniently used to print parse trees in these formats.

Pretty

Pretty print the parse tree.

prettyString($$)

Return a readable string representing a node of a parse tree and all the nodes below it. Or use -p $node

     Parameter  Description
  1  $node      Start node
  2  $depth     Optional depth.

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    my $a = Data::Edit::Xml::new($s);

    ok $s eq $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴;

    ok $s eq -p $a;

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bbb</b>.
    <c>ccc</c>.
  </a>
  END

    ok nn(-p $a) eq qq(<a>N  <b>bbb</b>.NN  N  <c>ccc</c>.NNN</a>N);

prettyStringDitaHeaders($)

Return a readable string representing the parse tree below the specified $node with appropriate headers as determined by ditaOrganization . Or use -x $node

     Parameter  Description
  1  $node      Start node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <concept/>
  END

    Data::Edit::Xml::ditaOrganization = q(ACT);

    ok $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗗𝗶𝘁𝗮𝗛𝗲𝗮𝗱𝗲𝗿𝘀 eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

    ok -x $a eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

prettyStringNumbered($$)

Return a readable string representing a node of a parse tree and all the nodes below it with a number attached to each tag. The node numbers can then be used as described in Order to monitor changes to the parse tree.

     Parameter  Description
  1  $node      Start node
  2  $depth     Optional depth.

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    $a->numberTree;

    ok $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗡𝘂𝗺𝗯𝗲𝗿𝗲𝗱 eq <<END;
  <a id="1">
    <b id="2">
      <A id="3"/>
      <B id="4"/>
    </b>
    <c id="5">
      <C id="6"/>
      <D id="7"/>
    </c>
  </a>
  END

prettyStringCDATA($$)

Return a readable string representing a node of a parse tree and all the nodes below it with the text fields wrapped with <CDATA>...</CDATA>.

     Parameter  Description
  1  $node      Start node
  2  $depth     Optional depth.

Example:

   {my $a = Data::Edit::Xml::new("<a><b>A</b></a>");

    my $b = $a->first;

       $b->first->replaceWithBlank;

    ok $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗖𝗗𝗔𝗧𝗔 eq <<END;
  <a>
      <b><CDATA> </CDATA></b>
  </a>
  END

prettyStringContent($)

Return a readable string representing all the nodes below a node of a parse tree.

     Parameter  Description
  1  $node      Start node.

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    ok $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗖𝗼𝗻𝘁𝗲𝗻𝘁 eq <<END;
  <b>
    <A/>
    <B/>
  </b>
  <c>
    <C/>
    <D/>
  </c>
  END

prettyStringContentNumbered($)

Return a readable string representing all the nodes below a node of a parse tree with numbering added.

     Parameter  Description
  1  $node      Start node.

Example:

   {my $s = <<END;
  <a>
    <b>
      <c/>
    </b>
  </a>
  END

    my $a = Data::Edit::Xml::new($s);

    $a->numberTree;

    ok $a->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗡𝘂𝗺𝗯𝗲𝗿𝗲𝗱 eq <<END;
  <b id="2">
    <c id="3"/>
  </b>
  END

    ok $a->go(qw(b))->𝗽𝗿𝗲𝘁𝘁𝘆𝗦𝘁𝗿𝗶𝗻𝗴𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗡𝘂𝗺𝗯𝗲𝗿𝗲𝗱 eq <<END;
  <c id="3"/>
  END

xmlHeader($)

Add the standard xml header to a string

     Parameter  Description
  1  $string    String to which a standard xml header should be prefixed

Example:

  ok 𝘅𝗺𝗹𝗛𝗲𝗮𝗱𝗲𝗿("<a/>") eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <a/>
  END

This is a static method and so should be invoked as:

  Data::Edit::Xml::xmlHeader

Dense

Print the parse tree.

string($)

Return a dense string representing a node of a parse tree and all the nodes below it. Or use -s $node.

     Parameter  Description
  1  $node      Start node.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok -s $a eq '<a><b><c id="42" match="mm"/></b><d><e/></d></a>';

stringMd5Sum($)

Return the md5 sum of the dense string representing a node of a parse tree and all the nodes below it. Or use -k $node.

     Parameter  Description
  1  $node      Node.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      c
    </b>
  </a>
  END

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗠𝗱𝟱𝗦𝘂𝗺 eq q(390bf05d8f5671cc6a4771834840d695);
    ok -k $a            eq q(390bf05d8f5671cc6a4771834840d695);
    ok -k $a            ne -k $a->first;
   }

stringQuoted($)

Return a quoted string representing a parse tree a node of a parse tree and all the nodes below it. Or use -o $node.

     Parameter  Description
  1  $node      Start node

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗤𝘂𝗼𝘁𝗲𝗱 eq q('<a><b><A/><B/></b><c><C/><D/></c></a>');

stringReplacingIdsWithLabels($)

Return a string representing the specified parse tree with the id attribute of each node set to the Labels attached to each node.

     Parameter  Description
  1  $node      Start node.

Example:

    ok $x->𝘀𝘁𝗿𝗶𝗻𝗴𝗥𝗲𝗽𝗹𝗮𝗰𝗶𝗻𝗴𝗜𝗱𝘀𝗪𝗶𝘁𝗵𝗟𝗮𝗯𝗲𝗹𝘀 eq '<a><b><c/></b></a>';

    $b->addLabels(1..4);

    $c->addLabels(5..8);

    ok $x->𝘀𝘁𝗿𝗶𝗻𝗴𝗥𝗲𝗽𝗹𝗮𝗰𝗶𝗻𝗴𝗜𝗱𝘀𝗪𝗶𝘁𝗵𝗟𝗮𝗯𝗲𝗹𝘀 eq '<a><b id="1, 2, 3, 4"><c id="5, 6, 7, 8"/></b></a>';

    my $s = $x->𝘀𝘁𝗿𝗶𝗻𝗴𝗥𝗲𝗽𝗹𝗮𝗰𝗶𝗻𝗴𝗜𝗱𝘀𝗪𝗶𝘁𝗵𝗟𝗮𝗯𝗲𝗹𝘀;

    ok $s eq '<a><b id="1, 2, 3, 4"><c id="5, 6, 7, 8"/></b></a>';

stringExtendingIdsWithLabels($)

Return a string representing the specified parse tree with the id attribute of each node extended by the Labels attached to each node.

     Parameter  Description
  1  $node      Start node.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a id="a">
    <b id="b">
      <c id="c"/>
    </b>
    <b id="B">
      <c id="C"/>
    </b>
  </a>
  END

    my $N = 0; $a->by(sub{$_->addLabels((-t $_).++$N)});

    ok -p (new $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗘𝘅𝘁𝗲𝗻𝗱𝗶𝗻𝗴𝗜𝗱𝘀𝗪𝗶𝘁𝗵𝗟𝗮𝗯𝗲𝗹𝘀) eq <<END;
  <a id="a, a5">
    <b id="b, b2">
      <c id="c, c1"/>
    </b>
    <b id="B, b4">
      <c id="C, c3"/>
    </b>
  </a>
  END

stringContent($)

Return a string representing all the nodes below a node of a parse tree.

     Parameter  Description
  1  $node      Start node.

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗖𝗼𝗻𝘁𝗲𝗻𝘁 eq "<b><A/><B/></b><c><C/><D/></c>";

stringNode($)

Return a string representing the specified $node showing the attributes, labels and node number.

     Parameter  Description
  1  $node      Node.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b><c/></b></a>';

    my $b = $x->go(q(b));

    $b->addLabels(1..2);

    $b->addLabels(3..4);

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c/></b></a>';

    $b->numberTree;

    ok -S $b eq "b(2) 0:1 1:2 2:3 3:4";

stringTagsAndText($)

Return a string showing just the tags and text at and below a specified $node.

     Parameter  Description
  1  $node      Node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->𝘀𝘁𝗿𝗶𝗻𝗴𝗧𝗮𝗴𝘀𝗔𝗻𝗱𝗧𝗲𝘅𝘁],   [qw(cc d dd c b)];
   is_deeply [$B->𝘀𝘁𝗿𝗶𝗻𝗴𝗧𝗮𝗴𝘀𝗔𝗻𝗱𝗧𝗲𝘅𝘁],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

stringText($)

Return a string showing just the text of the text nodes (separated by blanks) at and below a specified $node.

     Parameter  Description
  1  $node      Node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->𝘀𝘁𝗿𝗶𝗻𝗴𝗧𝗲𝘅𝘁],          [qw(cc dd)];
   is_deeply [$B->𝘀𝘁𝗿𝗶𝗻𝗴𝗧𝗲𝘅𝘁],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

setRepresentationAsTagsAndText($)

Sets the representationLast for every node in the specified $tree via stringTagsAndText.

     Parameter  Description
  1  $tree      Tree of nodes.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->𝘀𝗲𝘁𝗥𝗲𝗽𝗿𝗲𝘀𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻𝗔𝘀𝗧𝗮𝗴𝘀𝗔𝗻𝗱𝗧𝗲𝘅𝘁;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

setRepresentationAsText($)

Sets the representationLast for every node in the specified $tree via stringText.

     Parameter  Description
  1  $tree      Tree of nodes.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->𝘀𝗲𝘁𝗥𝗲𝗽𝗿𝗲𝘀𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻𝗔𝘀𝗧𝗲𝘅𝘁;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

matchNodesByRepresentation($)

Creates a hash of arrays of nodes that have the same representation in the specified $tree. Set representation for each node in the tree before calling this method.

     Parameter  Description
  1  $tree      Tree to examine

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->𝗺𝗮𝘁𝗰𝗵𝗡𝗼𝗱𝗲𝘀𝗕𝘆𝗥𝗲𝗽𝗿𝗲𝘀𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->𝗺𝗮𝘁𝗰𝗵𝗡𝗼𝗱𝗲𝘀𝗕𝘆𝗥𝗲𝗽𝗿𝗲𝘀𝗲𝗻𝘁𝗮𝘁𝗶𝗼𝗻;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

Conditions

Print a subset of the the parse tree determined by the conditions attached to it.

stringWithConditions($@)

Return a string representing the specified $node of a parse tree and all the nodes below it subject to conditions to select or reject some nodes.

     Parameter    Description
  1  $node        Start node
  2  @conditions  Conditions to be regarded as in effect.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my $b = $a >= 'b';

    my ($c, $d) = $b->contents;

    $b->addConditions(qw(bb BB));

    $c->addConditions(qw(cc CC));

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗪𝗶𝘁𝗵𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀         eq '<a><b><c/><d/></b></a>';

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗪𝗶𝘁𝗵𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(bb)) eq '<a><b><d/></b></a>';

    ok $a->𝘀𝘁𝗿𝗶𝗻𝗴𝗪𝗶𝘁𝗵𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(cc)) eq '<a/>';

condition($$@)

Return the node if it has the specified condition and is in the optional context, else return undef

     Parameter   Description
  1  $node       Node
  2  $condition  Condition to check
  3  @context    Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    $b->addConditions(qw(bb BB));

    $c->addConditions(qw(cc CC));

    ok  $c->𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻(q(cc));

    ok !$c->𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻(q(dd));

    ok  $c->𝗰𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻(q(cc), qw(c b a));

anyCondition($@)

Return the node if it has any of the specified conditions, else return undef

     Parameter    Description
  1  $node        Node
  2  @conditions  Conditions to check

Example:

    $b->addConditions(qw(bb BB));

    $c->addConditions(qw(cc CC));

    ok  $b->𝗮𝗻𝘆𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻(qw(bb cc));

    ok !$b->𝗮𝗻𝘆𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻(qw(cc CC));

allConditions($@)

Return the node if it has all of the specified conditions, else return undef

     Parameter    Description
  1  $node        Node
  2  @conditions  Conditions to check

Example:

    $b->addConditions(qw(bb BB));

    $c->addConditions(qw(cc CC));

    ok  $b->𝗮𝗹𝗹𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(bb BB));

    ok !$b->𝗮𝗹𝗹𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(bb cc));

addConditions($@)

Add conditions to a node and return the node.

     Parameter    Description
  1  $node        Node
  2  @conditions  Conditions to add.

Example:

    $b->𝗮𝗱𝗱𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(bb BB));

    ok join(' ', $b->listConditions) eq 'BB bb';

deleteConditions($@)

Delete conditions applied to a node and return the node.

     Parameter    Description
  1  $node        Node
  2  @conditions  Conditions to add.

Example:

    ok join(' ', $b->listConditions) eq 'BB bb';

    $b->𝗱𝗲𝗹𝗲𝘁𝗲𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀(qw(BB));

    ok join(' ', $b->listConditions) eq 'bb';

listConditions($)

Return a list of conditions applied to a node.

     Parameter  Description
  1  $node      Node.

Example:

    $b->addConditions(qw(bb BB));

    ok join(' ', $b->𝗹𝗶𝘀𝘁𝗖𝗼𝗻𝗱𝗶𝘁𝗶𝗼𝗻𝘀) eq 'BB bb';

Attributes

Get or set the attributes of nodes in the parse tree. Well Known Attributes can be set directly via lvalue subs. To set or get the values of other attributes use Get or Set Attributes. To delete or rename attributes see: Other Operations on Attributes.

Well Known Attributes

Get or set these node attributes via lvalue subs as in:

  $x->href = "#ref";

Get or Set Attributes

Get or set the attributes of nodes.

attr($$)

Return the value of an attribute of the current node as an lvalue sub.

     Parameter   Description
  1  $node       Node in parse tree
  2  $attribute  Attribute name.

Example:

   {my $x = Data::Edit::Xml::new(my $s = <<END);
  <a number="1"/>
  END

    ok $x->𝗮𝘁𝘁𝗿(qq(number)) == 1;

       $x->𝗮𝘁𝘁𝗿(qq(number))  = 2;

    ok $x->𝗮𝘁𝘁𝗿(qq(number)) == 2;

    ok -s $x eq '<a number="2"/>';

attrX($$)

Return the value of the specified $attribute of the specified $node or q() if the $node does not have such an attribute.

     Parameter   Description
  1  $node       Node in parse tree
  2  $attribute  Attribute name.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b name="bb"/></a>));

    my  $b = $a->first;
    ok  $b->attrX_name eq q(bb);
    ok !$b->attrX_bbb;
   }

set($%)

Set the values of some attributes in a node and return the node. Identical in effect to setAttr.

     Parameter  Description
  1  $node      Node in parse tree
  2  %values    (attribute name=>new value)*

Example:

    ok q(<a a="1" b="1" id="aa"/>) eq -s $a;

    $a->𝘀𝗲𝘁(a=>11, b=>undef, c=>3, d=>4, e=>5);

   }

setAttr($%)

Set the values of some attributes in a node and return the node. Identical in effect to set.

     Parameter  Description
  1  $node      Node in parse tree
  2  %values    (attribute name=>new value)*

Example:

    ok -s $x eq '<a number="2"/>';

    $x->𝘀𝗲𝘁𝗔𝘁𝘁𝗿(first=>1, second=>2, last=>undef);

    ok -s $x eq '<a first="1" number="2" second="2"/>';

Other Operations on Attributes

Perform operations other than get or set on the attributes of a node

attrs($@)

Return the values of the specified attributes of the current node as a list

     Parameter    Description
  1  $node        Node in parse tree
  2  @attributes  Attribute names.

Example:

    ok -s $x eq '<a first="1" number="2" second="2"/>';

    is_deeply [$x->𝗮𝘁𝘁𝗿𝘀(qw(third second first ))], [undef, 2, 1];

attrCount($@)

Return the number of attributes in the specified $node, optionally ignoring the specified names from the count.

     Parameter  Description
  1  $node      Node in parse tree
  2  @exclude   Optional attribute names to exclude from the count.

Example:

    ok -s $x eq '<a first="1" number="2" second="2"/>';

    ok $x->𝗮𝘁𝘁𝗿𝗖𝗼𝘂𝗻𝘁 == 3;

    ok $x->𝗮𝘁𝘁𝗿𝗖𝗼𝘂𝗻𝘁(qw(first second third)) == 1;

getAttrs($)

Return a sorted list of all the attributes on the specified $node.

     Parameter  Description
  1  $node      Node in parse tree.

Example:

    ok -s $x eq '<a first="1" number="2" second="2"/>';

    is_deeply [$x->𝗴𝗲𝘁𝗔𝘁𝘁𝗿𝘀], [qw(first number second)];

deleteAttr($$$)

Delete the named attribute in the specified $node, optionally check its value first, return the node regardless.

     Parameter  Description
  1  $node      Node
  2  $attr      Attribute name
  3  $value     Optional attribute value to check first.

Example:

    ok -s $x eq '<a delete="me" number="2"/>';

    $x->𝗱𝗲𝗹𝗲𝘁𝗲𝗔𝘁𝘁𝗿(qq(delete));

    ok -s $x eq '<a number="2"/>';

deleteAttrs($@)

Delete the specified attributes of the specified $node without checking their values and return the node.

     Parameter  Description
  1  $node      Node
  2  @attrs     Names of the attributes to delete

Example:

    ok -s $x eq '<a first="1" number="2" second="2"/>';

    $x->𝗱𝗲𝗹𝗲𝘁𝗲𝗔𝘁𝘁𝗿𝘀(qw(first second third number));

    ok -s $x eq '<a/>';

deleteAttrsInTree($@)

Delete the specified attributes of the specified $node and all the nodes under it and return the specified $node.

     Parameter  Description
  1  $node      Node
  2  @attrs     Names of the attributes to delete

Example:

    ok -p $a eq <<END;
  <a class="2" id="0">
    <b class="1" id="1">
      <c class="0" id="0">
        <d class="1" id="1"/>
        <e class="2" id="0"/>
        <e class="0" id="1"/>
        <f class="1" id="0"/>
        <f class="2" id="1"/>
      </c>
    </b>
  </a>
  END

    $a->deleteAttrsInTree_class;

    ok -p $a eq <<END
  <a id="0">
    <b id="1">
      <c id="0">
        <d id="1"/>
        <e id="0"/>
        <e id="1"/>
        <f id="0"/>
        <f id="1"/>
      </c>
    </b>
  </a>
  END

deleteAttrValueAtInTree($$$@)

Delete all instances of the specified $attribute with the specified $value in the specified @context in the specified $tree and return the modified $tree. An undefined $value will cause the attribute to be deleted without first confirming its value. An empty context will remove the attribute from every node in the $tree.

     Parameter   Description
  1  $tree       Tree
  2  $attribute  Attribute name
  3  $value      Attribute value or B<undef> for all values
  4  @context    Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
     <c id="c"/>
     <c id="d"/>
   </b>
   <d>
     <c id="c"/>
     <c id="d"/>
   </d>
  </a>
  END

    $a->deleteAttrValueAtInTree_id_c_c_b;
    ok -p $a eq <<END;
  <a>
    <b>
      <c/>
      <c id="d"/>
    </b>
    <d>
      <c id="c"/>
      <c id="d"/>
    </d>
  </a>
  END
   }

renameAttr($$$)

Change the name of an attribute in the specified $node regardless of whether the new attribute already exists or not and return the node. To prevent inadvertent changes to an existing attribute use changeAttr.

     Parameter  Description
  1  $node      Node
  2  $old       Existing attribute name
  3  $new       New attribute name.

Example:

    ok $x->printAttributes eq qq( no="1" word="first");

    $x->𝗿𝗲𝗻𝗮𝗺𝗲𝗔𝘁𝘁𝗿(qw(no number));

    ok $x->printAttributes eq qq( number="1" word="first");

changeAttr($$$)

Change the name of an attribute in the specified $node unless it has already been set and return the node. To make changes regardless of whether the new attribute already exists use renameAttr.

     Parameter  Description
  1  $node      Node
  2  $old       Existing attribute name
  3  $new       New attribute name.

Example:

    ok $x->printAttributes eq qq( number="1" word="first");

    $x->𝗰𝗵𝗮𝗻𝗴𝗲𝗔𝘁𝘁𝗿(qw(number word));

    ok $x->printAttributes eq qq( number="1" word="first");

renameAttrValue($$$$$)

Change the name and value of an attribute in the specified $node regardless of whether the new attribute already exists or not and return the node. To prevent inadvertent changes to existing attributes use changeAttrValue.

     Parameter  Description
  1  $node      Node
  2  $old       Existing attribute name
  3  $oldValue  Existing attribute value
  4  $new       New attribute name
  5  $newValue  New attribute value.

Example:

    ok $x->printAttributes eq qq( number="1" word="first");

    $x->𝗿𝗲𝗻𝗮𝗺𝗲𝗔𝘁𝘁𝗿𝗩𝗮𝗹𝘂𝗲(qw(number 1 numeral I));

    ok $x->printAttributes eq qq( numeral="I" word="first");

changeAttrValue($$$$$)

Change the name and value of an attribute in the specified $node unless it has already been set and return the node. To make changes regardless of whether the new attribute already exists use renameAttrValue.

     Parameter  Description
  1  $node      Node
  2  $old       Existing attribute name
  3  $oldValue  Existing attribute value
  4  $new       New attribute name
  5  $newValue  New attribute value.

Example:

    ok $x->printAttributes eq qq( numeral="I" word="first");

    $x->𝗰𝗵𝗮𝗻𝗴𝗲𝗔𝘁𝘁𝗿𝗩𝗮𝗹𝘂𝗲(qw(word second greek mono));

    ok $x->printAttributes eq qq( numeral="I" word="first");

    $x->𝗰𝗵𝗮𝗻𝗴𝗲𝗔𝘁𝘁𝗿𝗩𝗮𝗹𝘂𝗲(qw(word first greek mono));

    ok $x->printAttributes eq qq( greek="mono" numeral="I");

changeAttributeValue($$$@)

Apply a sub to the value of an attribute of the specified $node. The value to be changed is supplied and returned in: $_.

     Parameter   Description
  1  $node       Node
  2  $attribute  Attribute name
  3  $sub        Change sub
  4  @context    Optional context;

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a aa="abc"/>
  END

    $a->𝗰𝗵𝗮𝗻𝗴𝗲𝗔𝘁𝘁𝗿𝗶𝗯𝘂𝘁𝗲𝗩𝗮𝗹𝘂𝗲(q(aa), sub{s(b) (B)});

    ok -p $a eq <<END;
  <a aa="aBc"/>
  END

copyAttrs($$@)

Copy all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, overwriting any existing attributes in the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node
  3  @attr      Optional list of attributes to copy

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    my ($a, $b, $c) = $x->contents;

    $a->𝗰𝗼𝗽𝘆𝗔𝘁𝘁𝗿𝘀($b, qw(aa bb));

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    $a->𝗰𝗼𝗽𝘆𝗔𝘁𝘁𝗿𝘀($b);

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b a="1" b="2" c="4"/>
    <c/>
  </x>
  END

copyNewAttrs($$@)

Copy all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, without overwriting any existing attributes in the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node
  3  @attr      Optional list of attributes to copy

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    my ($a, $b, $c) = $x->contents;

    $a->𝗰𝗼𝗽𝘆𝗡𝗲𝘄𝗔𝘁𝘁𝗿𝘀($b, qw(aa bb));

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    $a->𝗰𝗼𝗽𝘆𝗡𝗲𝘄𝗔𝘁𝘁𝗿𝘀($b);

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b a="1" b="3" c="4"/>
    <c/>
  </x>
  END

moveAttrs($$@)

Move all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to move is supplied, overwriting any existing attributes in the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node
  3  @attr      Attributes to move

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    my ($a, $b, $c) = $x->contents;

    $a->𝗺𝗼𝘃𝗲𝗔𝘁𝘁𝗿𝘀($c, qw(aa bb));

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b a="1" b="2" c="4"/>
    <c/>
  </x>
  END

    $b->𝗺𝗼𝘃𝗲𝗔𝘁𝘁𝗿𝘀($c);

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b/>
    <c a="1" b="2" c="4"/>
  </x>
  END

moveNewAttrs($$@)

Move all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, without overwriting any existing attributes in the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node
  3  @attr      Optional list of attributes to move

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a a="1" b="2"/>
    <b b="3" c="4"/>
    <c/>
  </x>
  END

    my ($a, $b, $c) = $x->contents;

    $b->𝗺𝗼𝘃𝗲𝗡𝗲𝘄𝗔𝘁𝘁𝗿𝘀($c, qw(aa bb));

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b a="1" b="3" c="4"/>
    <c/>
  </x>
  END

    $b->𝗺𝗼𝘃𝗲𝗡𝗲𝘄𝗔𝘁𝘁𝗿𝘀($c);

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b/>
    <c a="1" b="3" c="4"/>
  </x>
  END

    ok <<END eq -p $x;
  <x>
    <c a="1" b="3" c="4"/>
    <b/>
    <a a="1" b="2"/>
  </x>
  END

Traversal

Traverse the parse tree in various orders applying a sub to each node.

Post-order

This order allows you to edit children before their parents.

by($$@)

Post-order traversal of a parse tree or sub tree calling the specified sub at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. A reference to the current node is also made available via $_. This is equivalent to the x= operator.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->𝗯𝘆(sub{$s .= $_->tag}); ok $s eq "cbeda"

byX($$)

Post-order traversal of a parse tree calling the specified sub at each node as long as this sub does not die. The traversal is halted if the called sub does die on any call with the reason in ?@ The sub is passed references to the current node and all of its ancestors up to the node on which this sub was called. A reference to the current node is also made available via $_.

Returns the start node regardless of the outcome of calling sub.

     Parameter  Description
  1  $node      Start node
  2  $sub       Sub to call

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->𝗯𝘆𝗫(sub{$s .= $_->tag}); ok $s eq "cbeda"

  sub 𝗯𝘆𝗫($$)
   {my ($node, $sub) = @_;                                                        # Start node, sub to call
    eval {$node->byX2($sub)};                                                     # Trap any errors that occur
    $node
   }

byList($@)

Return a list of all the nodes at and below a specified $node in post-order or the empty list if the $node is not in the optional context.

     Parameter  Description
  1  $node      Starting node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok -c $e eq q(e d a);

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
   </b>
   <e/>
   <f>
    <g/>
    <h/>
   </f>
  </a>
  END

    ok q(c d b e g h f a) eq join ' ', map{-t $_} $a->𝗯𝘆𝗟𝗶𝘀𝘁;
    ok q(h g f e d c b a) eq join ' ', map{-t $_} $a->byReverseList;
    ok q(a b c d e f g h) eq join ' ', map{-t $_} $a->downList;
    ok q(a f h g e b d c) eq join ' ', map{-t $_} $a->downReverseList;
   }

byReverse($$@)

Reverse post-order traversal of a parse tree or sub tree calling the specified sub at each node and returning the specified starting $node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->𝗯𝘆𝗥𝗲𝘃𝗲𝗿𝘀𝗲(sub{$s .= $_->tag}); ok $s eq "edcba"

byReverseX($$@)

Reverse post-order traversal of a parse tree or sub tree below the specified $node calling the specified sub within eval{} at each node and returning the specified starting $node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->byReverse(sub{$s .= $_->tag}); ok $s eq "edcba"

byReverseList($@)

Return a list of all the nodes at and below a specified $node in reverse preorder or the empty list if the specified $node is not in the optional context.

     Parameter  Description
  1  $node      Starting node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

      my ($E, $D, $C, $B) = $a->𝗯𝘆𝗥𝗲𝘃𝗲𝗿𝘀𝗲𝗟𝗶𝘀𝘁;

      ok -A $C eq q(c id="42" match="mm");

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
   </b>
   <e/>
   <f>
    <g/>
    <h/>
   </f>
  </a>
  END

    ok q(c d b e g h f a) eq join ' ', map{-t $_} $a->byList;
    ok q(h g f e d c b a) eq join ' ', map{-t $_} $a->𝗯𝘆𝗥𝗲𝘃𝗲𝗿𝘀𝗲𝗟𝗶𝘀𝘁;
    ok q(a b c d e f g h) eq join ' ', map{-t $_} $a->downList;
    ok q(a f h g e b d c) eq join ' ', map{-t $_} $a->downReverseList;
   }

Pre-order

This order allows you to edit children after their parents

down($$@)

Pre-order traversal down through a parse tree or sub tree calling the specified sub at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

     {my $s; $a->𝗱𝗼𝘄𝗻(sub{$s .= $_->tag}); ok $s eq "abcde"

downX($$)

Pre-order traversal of a parse tree calling the specified sub at each node as long as this sub does not die. The traversal is halted if the called sub does die on any call with the reason in ?@ The sub is passed references to the current node and all of its ancestors up to the node on which this sub was called. A reference to the current node is also made available via $_.

Returns the start node regardless of the outcome of calling sub.

     Parameter  Description
  1  $node      Start node
  2  $sub       Sub to call

Example:

     {my $s; $a->down(sub{$s .= $_->tag}); ok $s eq "abcde"

  sub 𝗱𝗼𝘄𝗻𝗫($$)
   {my ($node, $sub) = @_;                                                        # Start node, sub to call
    eval {$node->downX2($sub)};                                                   # Trap any errors that occur
    $node
   }

downList($@)

Return a list of all the nodes at and below a specified $node in pre-order or the empty list if the $node is not in the optional context.

     Parameter  Description
  1  $node      Starting node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
   </b>
   <e/>
   <f>
    <g/>
    <h/>
   </f>
  </a>
  END

    ok q(c d b e g h f a) eq join ' ', map{-t $_} $a->byList;
    ok q(h g f e d c b a) eq join ' ', map{-t $_} $a->byReverseList;
    ok q(a b c d e f g h) eq join ' ', map{-t $_} $a->𝗱𝗼𝘄𝗻𝗟𝗶𝘀𝘁;
    ok q(a f h g e b d c) eq join ' ', map{-t $_} $a->downReverseList;
   }

downReverse($$@)

Reverse pre-order traversal down through a parse tree or sub tree calling the specified sub at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->𝗱𝗼𝘄𝗻𝗥𝗲𝘃𝗲𝗿𝘀𝗲(sub{$s .= $_->tag}); ok $s eq "adebc"

downReverseX($$@)

Reverse pre-order traversal down through a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a->downReverse(sub{$s .= $_->tag}); ok $s eq "adebc"

downReverseList($@)

Return a list of all the nodes at and below a specified $node in reverse pre-order or the empty list if the $node is not in the optional context.

     Parameter  Description
  1  $node      Starting node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
   </b>
   <e/>
   <f>
    <g/>
    <h/>
   </f>
  </a>
  END

    ok q(c d b e g h f a) eq join ' ', map{-t $_} $a->byList;
    ok q(h g f e d c b a) eq join ' ', map{-t $_} $a->byReverseList;
    ok q(a b c d e f g h) eq join ' ', map{-t $_} $a->downList;
    ok q(a f h g e b d c) eq join ' ', map{-t $_} $a->𝗱𝗼𝘄𝗻𝗥𝗲𝘃𝗲𝗿𝘀𝗲𝗟𝗶𝘀𝘁;
   }

Pre and Post order

Visit the parent first, then the children, then the parent again.

through($$$@)

Traverse parse tree visiting each node twice calling the specified sub $before as we go down past the node and sub $after as we go up past the node, finally return the specified starting node. The subs $before, $after are passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $before    Sub to call when we meet a node
  3  $after     Sub to call we leave a node
  4  @context   Accumulated context.

Example:

     {my $s; my $n = sub{$s .= $_->tag}; $a->𝘁𝗵𝗿𝗼𝘂𝗴𝗵($n, $n);

      ok $s eq "abccbdeeda"

throughX($$$@)

Identical to through except the $before, $after subs are called in an eval block to prevent die terminating the traversal of the full tree.

     Parameter  Description
  1  $node      Starting node
  2  $before    Sub to call when we meet a node
  3  $after     Sub to call we leave a node
  4  @context   Accumulated context.

Example:

     {my $s; my $n = sub{$s .= $_->tag}; $a->through($n, $n);

      ok $s eq "abccbdeeda"

Range

Ranges of nodes

from($@)

Return a list consisting of the specified node and its following siblings optionally including only those nodes that match one of the tags in the specified list.

     Parameter  Description
  1  $start     Start node
  2  @match     Optional list of tags to match

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

     {my ($d, $c, $D) = $a->findByNumbers(5, 7, 10);

      my @f = $d->𝗳𝗿𝗼𝗺;

      ok @f == 4;

      ok $d == $f[0];

      my @F = $d->𝗳𝗿𝗼𝗺(qw(c));

      ok @F == 2;

      ok -M $F[1] == 12;

      ok $D == $t[-1];

to($@)

Return a list of the sibling nodes preceding the specified node optionally including only those nodes that match one of the tags in the specified list.

     Parameter  Description
  1  $end       End node
  2  @match     Optional list of tags to match

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

     {my ($d, $c, $D) = $a->findByNumbers(5, 7, 10);

      my @t = $D->𝘁𝗼;

      ok @t == 4;

      my @T = $D->𝘁𝗼(qw(c));

      ok @T == 2;

      ok -M $T[1] == 7;

fromTo($$@)

Return a list of the nodes between the specified start and end nodes optionally including only those nodes that match one of the tags in the specified list.

     Parameter  Description
  1  $start     Start node
  2  $end       End node
  3  @match     Optional list of tags to match

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

     {my ($d, $c, $D) = $a->findByNumbers(5, 7, 10);

      my @r = $d->𝗳𝗿𝗼𝗺𝗧𝗼($D);

      ok @r == 3;

      my @R = $d->𝗳𝗿𝗼𝗺𝗧𝗼($D, qw(c));

      ok @R == 1;

      ok -M $R[0] == 7;

      ok !$D->𝗳𝗿𝗼𝗺𝗧𝗼($d);

      ok 1 == $d->𝗳𝗿𝗼𝗺𝗧𝗼($d);

Location

Locate the line numbers and columns of a specified node and write that information as a Oxygen Message.

lineLocation($)

Return the line number.column location of this tag in its source file or string if the source was parsed with the line number option on.

     Parameter  Description
  1  $node      Node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1, inputFile=>q(aaa.xml));
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  <test id="t1">
   <title>Test_</title>
    <testbody>
      <setup>
        <p>Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks>
        <p>Make sure the pot is on an insulated surface.</p>
      </checks>
      <run>
        <p>Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results>
        <p>Pour the tea into a cup.</p>
      </results>
      <outcome>
        <p>An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok -p $a eq <<END;
  <test id="t1" xtrf="3.1:3.14">
    <title xtrf="4.2:4.8">Test_</title>
    <testbody xtrf="5.3:5.12">
      <setup xtrf="6.5:6.11">
        <p xtrf="7.7:7.9">Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks xtrf="9.5:9.12">
        <p xtrf="10.7:10.9">Make sure the pot is on an insulated surface.</p>
      </checks>
      <run xtrf="12.5:12.9">
        <p xtrf="13.7:13.9">Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results xtrf="15.5:15.13">
        <p xtrf="16.7:16.9">Pour the tea into a cup.</p>
      </results>
      <outcome xtrf="18.5:18.13">
        <p xtrf="19.7:19.9">An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok $a->go_testbody_run_p__location eq q( on line 13 from 7 to 9 in file: aaa.xml);

    my $p = $a->go_testbody_run_p;
    $p->putNext(my $q = $p->newTag_hello);
    ok $p->𝗹𝗶𝗻𝗲𝗟𝗼𝗰𝗮𝘁𝗶𝗼𝗻 eq q(on line 13 from 7 to 9);

    ok $q->location eq q( in file: aaa.xml);
    ok $q->closestLocation == $p;
    ok $q->approxLocation eq q( on line 13 from 7 to 9 in file: aaa.xml);

    ok $q->formatOxygenMessage(q(E), q(), q(Hello detected)) eq <<END;
  Type: E
  Line: 13
  Column: 7
  EndLine: 13
  EndColumn: 9
  AdditionalInfoURL:
  Description: Hello detected
  END
   }

location($$)

Return the line number.column plus file location of this tag in its source file or string if the source was parsed with the line number option on.

     Parameter  Description
  1  $node      Node
  2  $file      Optionally the location of the source.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1, inputFile=>q(aaa.xml));
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  <test id="t1">
   <title>Test_</title>
    <testbody>
      <setup>
        <p>Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks>
        <p>Make sure the pot is on an insulated surface.</p>
      </checks>
      <run>
        <p>Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results>
        <p>Pour the tea into a cup.</p>
      </results>
      <outcome>
        <p>An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok -p $a eq <<END;
  <test id="t1" xtrf="3.1:3.14">
    <title xtrf="4.2:4.8">Test_</title>
    <testbody xtrf="5.3:5.12">
      <setup xtrf="6.5:6.11">
        <p xtrf="7.7:7.9">Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks xtrf="9.5:9.12">
        <p xtrf="10.7:10.9">Make sure the pot is on an insulated surface.</p>
      </checks>
      <run xtrf="12.5:12.9">
        <p xtrf="13.7:13.9">Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results xtrf="15.5:15.13">
        <p xtrf="16.7:16.9">Pour the tea into a cup.</p>
      </results>
      <outcome xtrf="18.5:18.13">
        <p xtrf="19.7:19.9">An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok $a->go_testbody_run_p__location eq q( on line 13 from 7 to 9 in file: aaa.xml);

    my $p = $a->go_testbody_run_p;
    $p->putNext(my $q = $p->newTag_hello);
    ok $p->lineLocation eq q(on line 13 from 7 to 9);

    ok $q->𝗹𝗼𝗰𝗮𝘁𝗶𝗼𝗻 eq q( in file: aaa.xml);
    ok $q->closestLocation == $p;
    ok $q->approxLocation eq q( on line 13 from 7 to 9 in file: aaa.xml);

    ok $q->formatOxygenMessage(q(E), q(), q(Hello detected)) eq <<END;
  Type: E
  Line: 13
  Column: 7
  EndLine: 13
  EndColumn: 9
  AdditionalInfoURL:
  Description: Hello detected
  END
   }

closestLocation($)

Return the nearest node with line number.column information

     Parameter  Description
  1  $node      Node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1, inputFile=>q(aaa.xml));
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  <test id="t1">
   <title>Test_</title>
    <testbody>
      <setup>
        <p>Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks>
        <p>Make sure the pot is on an insulated surface.</p>
      </checks>
      <run>
        <p>Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results>
        <p>Pour the tea into a cup.</p>
      </results>
      <outcome>
        <p>An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok -p $a eq <<END;
  <test id="t1" xtrf="3.1:3.14">
    <title xtrf="4.2:4.8">Test_</title>
    <testbody xtrf="5.3:5.12">
      <setup xtrf="6.5:6.11">
        <p xtrf="7.7:7.9">Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks xtrf="9.5:9.12">
        <p xtrf="10.7:10.9">Make sure the pot is on an insulated surface.</p>
      </checks>
      <run xtrf="12.5:12.9">
        <p xtrf="13.7:13.9">Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results xtrf="15.5:15.13">
        <p xtrf="16.7:16.9">Pour the tea into a cup.</p>
      </results>
      <outcome xtrf="18.5:18.13">
        <p xtrf="19.7:19.9">An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok $a->go_testbody_run_p__location eq q( on line 13 from 7 to 9 in file: aaa.xml);

    my $p = $a->go_testbody_run_p;
    $p->putNext(my $q = $p->newTag_hello);
    ok $p->lineLocation eq q(on line 13 from 7 to 9);

    ok $q->location eq q( in file: aaa.xml);
    ok $q->𝗰𝗹𝗼𝘀𝗲𝘀𝘁𝗟𝗼𝗰𝗮𝘁𝗶𝗼𝗻 == $p;
    ok $q->approxLocation eq q( on line 13 from 7 to 9 in file: aaa.xml);

    ok $q->formatOxygenMessage(q(E), q(), q(Hello detected)) eq <<END;
  Type: E
  Line: 13
  Column: 7
  EndLine: 13
  EndColumn: 9
  AdditionalInfoURL:
  Description: Hello detected
  END
   }

approxLocation($$)

Return the line number.column location of the node nearest to this node in the source file if the source was parsed with the line number option on.

     Parameter  Description
  1  $node      Node
  2  $file      Optionally the location of the source.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1, inputFile=>q(aaa.xml));
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  <test id="t1">
   <title>Test_</title>
    <testbody>
      <setup>
        <p>Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks>
        <p>Make sure the pot is on an insulated surface.</p>
      </checks>
      <run>
        <p>Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results>
        <p>Pour the tea into a cup.</p>
      </results>
      <outcome>
        <p>An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok -p $a eq <<END;
  <test id="t1" xtrf="3.1:3.14">
    <title xtrf="4.2:4.8">Test_</title>
    <testbody xtrf="5.3:5.12">
      <setup xtrf="6.5:6.11">
        <p xtrf="7.7:7.9">Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks xtrf="9.5:9.12">
        <p xtrf="10.7:10.9">Make sure the pot is on an insulated surface.</p>
      </checks>
      <run xtrf="12.5:12.9">
        <p xtrf="13.7:13.9">Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results xtrf="15.5:15.13">
        <p xtrf="16.7:16.9">Pour the tea into a cup.</p>
      </results>
      <outcome xtrf="18.5:18.13">
        <p xtrf="19.7:19.9">An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok $a->go_testbody_run_p__location eq q( on line 13 from 7 to 9 in file: aaa.xml);

    my $p = $a->go_testbody_run_p;
    $p->putNext(my $q = $p->newTag_hello);
    ok $p->lineLocation eq q(on line 13 from 7 to 9);

    ok $q->location eq q( in file: aaa.xml);
    ok $q->closestLocation == $p;
    ok $q->𝗮𝗽𝗽𝗿𝗼𝘅𝗟𝗼𝗰𝗮𝘁𝗶𝗼𝗻 eq q( on line 13 from 7 to 9 in file: aaa.xml);

    ok $q->formatOxygenMessage(q(E), q(), q(Hello detected)) eq <<END;
  Type: E
  Line: 13
  Column: 7
  EndLine: 13
  EndColumn: 9
  AdditionalInfoURL:
  Description: Hello detected
  END
   }

formatOxygenMessage($$$@)

Write an error message in Oxygen format

     Parameter  Description
  1  $node      Node
  2  $level     Error level [F|E|W]
  3  $url       Explanatory Url
  4  @message   Message text

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END, lineNumbers=>1, inputFile=>q(aaa.xml));
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
  <test id="t1">
   <title>Test_</title>
    <testbody>
      <setup>
        <p>Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks>
        <p>Make sure the pot is on an insulated surface.</p>
      </checks>
      <run>
        <p>Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results>
        <p>Pour the tea into a cup.</p>
      </results>
      <outcome>
        <p>An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok -p $a eq <<END;
  <test id="t1" xtrf="3.1:3.14">
    <title xtrf="4.2:4.8">Test_</title>
    <testbody xtrf="5.3:5.12">
      <setup xtrf="6.5:6.11">
        <p xtrf="7.7:7.9">Place the boiling water and fresh tea in the pot.</p>
      </setup>
      <checks xtrf="9.5:9.12">
        <p xtrf="10.7:10.9">Make sure the pot is on an insulated surface.</p>
      </checks>
      <run xtrf="12.5:12.9">
        <p xtrf="13.7:13.9">Stir with a spoon then let brew for 5 minutes.</p>
      </run>
      <results xtrf="15.5:15.13">
        <p xtrf="16.7:16.9">Pour the tea into a cup.</p>
      </results>
      <outcome xtrf="18.5:18.13">
        <p xtrf="19.7:19.9">An enjoyable cup of tea.</p>
      </outcome>
    </testbody>
  </test>
  END

    ok $a->go_testbody_run_p__location eq q( on line 13 from 7 to 9 in file: aaa.xml);

    my $p = $a->go_testbody_run_p;
    $p->putNext(my $q = $p->newTag_hello);
    ok $p->lineLocation eq q(on line 13 from 7 to 9);

    ok $q->location eq q( in file: aaa.xml);
    ok $q->closestLocation == $p;
    ok $q->approxLocation eq q( on line 13 from 7 to 9 in file: aaa.xml);

    ok $q->𝗳𝗼𝗿𝗺𝗮𝘁𝗢𝘅𝘆𝗴𝗲𝗻𝗠𝗲𝘀𝘀𝗮𝗴𝗲(q(E), q(), q(Hello detected)) eq <<END;
  Type: E
  Line: 13
  Column: 7
  EndLine: 13
  EndColumn: 9
  AdditionalInfoURL:
  Description: Hello detected
  END
   }

Position

Confirm that the position navigated to is the expected position.

at($@)

Confirm that the specified $node has the specified ancestry and return the specified $node if it does else undef. Ancestry is specified by providing the expected tags that the $node's parent, the parent's parent etc. must match at each level. If undef is specified then any tag is assumed to match at that level. If a regular expression is specified then the current parent node tag must match the regular expression at that level. If all supplied tags match successfully then the starting node is returned else undef

     Parameter  Description
  1  $node      Node
  2  @context   Ancestry.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c> <d/> </c>
      <c> <e/> </c>
      <c> <f/> </c>
    </b>
  </a>
  END

    ok  $a->go(qw(b c -1 f))->𝗮𝘁(qw(f c b a));

    ok  $a->go(qw(b c  1 e))->𝗮𝘁(undef, qr(c|d), undef, qq(a));

    ok $d->context eq q(d c b a);

    ok  $d->𝗮𝘁(qw(d c b), undef);

    ok !$d->𝗮𝘁(qw(d c b), undef, undef);

    ok !$d->𝗮𝘁(qw(d e b));

attrValueAt($$$@)

Return the specified $node if it has the specified $attribute with the specified $value and the optional specified ancestry else return undef.

     Parameter   Description
  1  $node       Starting node
  2  $attribute  Attribute
  3  $value      Wanted value of attribute
  4  @context    Ancestry.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b c="C"/></a>));
    my $b = $a->first;
    ok !$b->attrValueAt_c_C_c_a;
    ok  $b->attrValueAt_c_C_b_a;
   }

not($@)

Return the specified $node if it does not match any of the specified tags, else undef

     Parameter  Description
  1  $node      Node
  2  @tags      Tags not to match

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
  </a>
  END

    ok $a->first->not_a_c;

atOrBelow($@)

Confirm that the node or one of its ancestors has the specified context as recognized by at and return the first node that matches the context or undef if none do.

     Parameter  Description
  1  $start     Starting node
  2  @context   Ancestry.

Example:

    ok $d->context eq q(d c b a);

    ok  $d->𝗮𝘁𝗢𝗿𝗕𝗲𝗹𝗼𝘄(qw(d c b a));

    ok  $d->𝗮𝘁𝗢𝗿𝗕𝗲𝗹𝗼𝘄(qw(  c b a));

    ok  $d->𝗮𝘁𝗢𝗿𝗕𝗲𝗹𝗼𝘄(qw(    b a));

    ok !$d->𝗮𝘁𝗢𝗿𝗕𝗲𝗹𝗼𝘄(qw(  c   a));

adjacent($$)

Return the first node if it is adjacent to the second node else undef.

     Parameter  Description
  1  $first     First node
  2  $second    Second node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok !$a->𝗮𝗱𝗷𝗮𝗰𝗲𝗻𝘁($B);

    ok  $b->𝗮𝗱𝗷𝗮𝗰𝗲𝗻𝘁($B);

ancestry($)

Return a list containing: (the specified $node, its parent, its parent's parent etc..). Or use upn to go up the specified number of levels.

     Parameter  Description
  1  $node      Starting node.

Example:

    $a->numberTree;

    ok $a->prettyStringNumbered eq <<END;
  <a id="1">
    <b id="2">
      <A id="3"/>
      <B id="4"/>
    </b>
    <c id="5">
      <C id="6"/>
      <D id="7"/>
    </c>
  </a>
  END

    is_deeply [map {-t $_} $a->findByNumber(7)->𝗮𝗻𝗰𝗲𝘀𝘁𝗿𝘆], [qw(D c a)];

context($)

Return a string containing the tag of the starting node and the tags of all its ancestors separated by single spaces.

     Parameter  Description
  1  $node      Starting node.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok $a->go(qw(d e))->𝗰𝗼𝗻𝘁𝗲𝘅𝘁 eq 'e d a';

containsSingleText($@)

Return the single text element below the specified $node else return undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new("<a><b>bb</b><c>cc<d/>ee</c></a>");

    ok  $a->go(q(b))->𝗰𝗼𝗻𝘁𝗮𝗶𝗻𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗧𝗲𝘅𝘁->text eq q(bb);

    ok !$a->go(q(c))->𝗰𝗼𝗻𝘁𝗮𝗶𝗻𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗧𝗲𝘅𝘁;

depth($)

Returns the depth of the specified $node, the depth of a root node is zero.

     Parameter  Description
  1  $node      Node.

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

    ok 0 == $a->𝗱𝗲𝗽𝘁𝗵;

    ok 4 == $a->findByNumber(14)->𝗱𝗲𝗽𝘁𝗵;

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b><c><d/></c><e/></b></a>));

    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
      </c>
      <e/>
    </b>
  </a>
  END

   my ($d, $c, $e, $b) = $a->byList;
   ok $a->height == 4;
   ok $a->𝗱𝗲𝗽𝘁𝗵  == 0;
   ok $c->𝗱𝗲𝗽𝘁𝗵  == 2;
   ok $c->height == 2;
   ok $e->𝗱𝗲𝗽𝘁𝗵  == 2;
   ok $e->height == 1;

   is_deeply [$a->depthProfile], [qw(4 3 3 2 1)];
  }

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

depthProfile($)

Returns the depth profile of the tree rooted at the specified $node.

     Parameter  Description
  1  $node      Node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b><c><d/></c><e/></b></a>));

    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
      </c>
      <e/>
    </b>
  </a>
  END

   my ($d, $c, $e, $b) = $a->byList;
   ok $a->height == 4;
   ok $a->depth  == 0;
   ok $c->depth  == 2;
   ok $c->height == 2;
   ok $e->depth  == 2;
   ok $e->height == 1;

   is_deeply [$a->𝗱𝗲𝗽𝘁𝗵𝗣𝗿𝗼𝗳𝗶𝗹𝗲], [qw(4 3 3 2 1)];
  }

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

setDepthProfile($)

Sets the depthProfile for every node in the specified $tree. The last set depthProfile for a specific niode can be retrieved from depthProfileLast.

     Parameter  Description
  1  $tree      Tree of nodes.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->𝘀𝗲𝘁𝗗𝗲𝗽𝘁𝗵𝗣𝗿𝗼𝗳𝗶𝗹𝗲;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

height($)

Returns the height of the tree rooted at the specified $node.

     Parameter  Description
  1  $node      Node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b><c><d/></c><e/></b></a>));

    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
      </c>
      <e/>
    </b>
  </a>
  END

   my ($d, $c, $e, $b) = $a->byList;
   ok $a->𝗵𝗲𝗶𝗴𝗵𝘁 == 4;
   ok $a->depth  == 0;
   ok $c->depth  == 2;
   ok $c->𝗵𝗲𝗶𝗴𝗵𝘁 == 2;
   ok $e->depth  == 2;
   ok $e->𝗵𝗲𝗶𝗴𝗵𝘁 == 1;

   is_deeply [$a->depthProfile], [qw(4 3 3 2 1)];
  }

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>cc
        <d/>
  dd
      </c>
    </b>
    <B>
      <c>cc
        <d/>
  dd
      </c>
    </B>
  </a>
  END

   my $b = $a->first_b; my $B = $a->last_B;
   my $c = $b->first_c; my $C = $B->first_c;
   my $d = $c->first_d; my $D = $C->first_d;

   $a->setDepthProfile;

   ok $b->depthProfileLast eq q(3 3 3 2 1);
   ok $b->depthProfileLast eq $B->depthProfileLast;

  # Represent using tags and text
   $a->setRepresentationAsTagsAndText;
   is_deeply [$b->stringTagsAndText],   [qw(cc d dd c b)];
   is_deeply [$B->stringTagsAndText],   [qw(cc d dd c B)];
   ok         $b->representationLast  eq qq(cc d dd c b);
   ok         $B->representationLast  eq qq(cc d dd c B);
   ok         $c->representationLast  eq qq(cc d dd c);
   ok         $C->representationLast  eq qq(cc d dd c);
   ok dump($b->representationLast) ne dump($B->representationLast);
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $m  = $a->matchNodesByRepresentation;

   my $bb = $b->representationLast;
   is_deeply $m->{$bb}, [$b];

   my $cc = $c->representationLast;
   is_deeply $m->{$cc}, [$c, $C];

  # Represent using just text
   $a->setRepresentationAsText;
   is_deeply [$b->stringText],          [qw(cc dd)];
   is_deeply [$B->stringText],          [qw(cc dd)];
   ok         $b->representationLast  eq qq(cc dd);
   ok         $B->representationLast  eq qq(cc dd);
   is_deeply  $b->representationLast,
              $B->representationLast;
   is_deeply  $c->representationLast,
              $C->representationLast;

   my $M  = $a->matchNodesByRepresentation;
   my $BB = $b->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   my $CC = $c->representationLast;
   is_deeply $M->{$BB}, [$c, $b, $C, $B];

   ok $b->representationLast eq $c->representationLast;
  }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->isOnlyChildText;
   }

isFirst($@)

Return the specified $node if it is first under its parent and optionally has the specified context, else return undef

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use isFirstNonBlank to skip a (rare) initial blank text CDATA. Use isFirstNonBlankX to die rather then receive a returned undef or false result.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok $a->go(q(b))->𝗶𝘀𝗙𝗶𝗿𝘀𝘁;

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok  $a->𝗶𝘀𝗙𝗶𝗿𝘀𝘁;

isFirstToDepth($$@)

Return the specified $node if it is first to the specified depth else return undef

     Parameter  Description
  1  $node      Node
  2  $depth     Depth
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $f, $e) = $a->byList;

    ok  $d->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(4);

    ok !$f->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(2);

    ok  $f->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(1);

    ok !$f->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(3);

isLast($@)

Return the specified $node if it is last under its parent and optionally has the specified context, else return undef

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use isLastNonBlank to skip a (rare) initial blank text CDATA. Use isLastNonBlankX to die rather then receive a returned undef or false result.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok $a->go(q(d))->𝗶𝘀𝗟𝗮𝘀𝘁;

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok  $a->𝗶𝘀𝗟𝗮𝘀𝘁;

isLastToDepth($$@)

Return the specified $node if it is last to the specified depth else return undef

     Parameter  Description
  1  $node      Node
  2  $depth     Depth
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $f, $e) = $a->byList;

    ok  $c->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(1);

    ok !$c->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(3);

    ok  $d->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(2);

    ok !$d->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗼𝗗𝗲𝗽𝘁𝗵(4);

isOnlyChild($@)

Return the specified $node if it is the only node under its parent ignoring any surrounding blank text.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $f, $e) = $a->byList;

    ok  $d->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

    ok !$d->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱(qw(b));

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok  $a->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

isOnlyChildToDepth($$@)

Return the specified $node if it and its ancestors are only children to the specified depth else return undef. isOnlyChildToDepth(1) is the same as isOnlychild

     Parameter  Description
  1  $node      Node
  2  $depth     Depth to which each parent node must also be an only child
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $f, $e) = $a->byList;

    ok  $d->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(1, qw(d c b a));

    ok  $d->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(2, qw(d c b a));

    ok !$d->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(3, qw(d c b a));

isOnlyChildText($@)

Return the specified $node if it is a text node and it is an only child else return undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    ok $a->first->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗧𝗲𝘅𝘁;
   }

hasSingleChild($@)

Return the only child of the specified $node if the child is the only node under its parent ignoring any surrounding blank text and has the optional specified context, else return undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b   id="b" b="bb">
      <b id="c" c="cc"/>
    </b>
  </a>
  END

    my ($c, $b) = $a->byList;

    is_deeply [$b->id, $c->id], [qw(b c)];

    ok $c == $b->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

    ok $b == $a->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

hasSingleChildToDepth($$@)

Return the specified $node if it has single children to at least the specified depth else return undef. hasSingleChildToDepth(0) is equivalent to hasSingleChild.

     Parameter  Description
  1  $node      Node
  2  $depth     Depth
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok $h == $g->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(1);

    ok $i == $g->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(2);

    ok      !$g->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(0);

    ok      !$g->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(3);

    ok $i == $i->𝗵𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱𝗧𝗼𝗗𝗲𝗽𝘁𝗵(0);

isEmpty($@)

Confirm that the specified $node is empty, that is: the specified $node has no content, not even a blank string of text. To test for blank nodes, see isAllBlankText.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>

  </a>
  END

    ok $x->𝗶𝘀𝗘𝗺𝗽𝘁𝘆;

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $f, $e) = $a->byList;

    ok  $d->𝗶𝘀𝗘𝗺𝗽𝘁𝘆;

over($$@)

Confirm that the string representing the tags at the level below the specified $node match a regular expression where each pair of tags is separated by a single space. Use contentAsTags to visualize the tags at the next level.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(q(b))->𝗼𝘃𝗲𝗿(qr(d.+e));

over2($$@)

Confirm that the string representing the tags at the level below the specified $node match a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space. This arrangement simplifies the regular expression used to detect combinations like p+ q? . Use contentAsTags2 to visualize the tags at the next level.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(q(b))->𝗼𝘃𝗲𝗿𝟮(qr(\A c  d  e  f  g \Z));

    ok $x->go(q(b))->contentAsTags  eq q(c d e f g) ;

overAllTags($@)

Return the specified b<$node> if all of it's child nodes match the specified <@tags> else return undef.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
  </a>
  END

    ok  $a->overAllTags_b_c_d;
    ok !$a->overAllTags_b_c;
    ok !$a->overAllTags_b_c_d_e;
    ok  $a->oat_b_c_d;
    ok !$a->oat_B_c_d;

    ok  $a->overFirstTags_b_c_d;
    ok  $a->overFirstTags_b_c;
    ok !$a->overFirstTags_b_c_d_e;
    ok  $a->oft_b_c;
    ok !$a->oft_B_c;

    ok  $a->overLastTags_b_c_d;
    ok  $a->overLastTags_c_d;
    ok !$a->overLastTags_b_c_d_e;
    ok  $a->olt_c_d;
    ok !$a->olt_C_d;
   }

oat is a synonym for overAllTags.

overFirstTags($@)

Return the specified b<$node> if the first of it's child nodes match the specified <@tags> else return undef.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
  </a>
  END

    ok  $a->overAllTags_b_c_d;
    ok !$a->overAllTags_b_c;
    ok !$a->overAllTags_b_c_d_e;
    ok  $a->oat_b_c_d;
    ok !$a->oat_B_c_d;

    ok  $a->overFirstTags_b_c_d;
    ok  $a->overFirstTags_b_c;
    ok !$a->overFirstTags_b_c_d_e;
    ok  $a->oft_b_c;
    ok !$a->oft_B_c;

    ok  $a->overLastTags_b_c_d;
    ok  $a->overLastTags_c_d;
    ok !$a->overLastTags_b_c_d_e;
    ok  $a->olt_c_d;
    ok !$a->olt_C_d;
   }

oft is a synonym for overFirstTags.

overLastTags($@)

Return the specified b<$node> if the last of it's child nodes match the specified <@tags> else return undef.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
  </a>
  END

    ok  $a->overAllTags_b_c_d;
    ok !$a->overAllTags_b_c;
    ok !$a->overAllTags_b_c_d_e;
    ok  $a->oat_b_c_d;
    ok !$a->oat_B_c_d;

    ok  $a->overFirstTags_b_c_d;
    ok  $a->overFirstTags_b_c;
    ok !$a->overFirstTags_b_c_d_e;
    ok  $a->oft_b_c;
    ok !$a->oft_B_c;

    ok  $a->overLastTags_b_c_d;
    ok  $a->overLastTags_c_d;
    ok !$a->overLastTags_b_c_d_e;
    ok  $a->olt_c_d;
    ok !$a->olt_C_d;
   }

olt is a synonym for overLastTags.

matchAfter($$@)

Confirm that the string representing the tags following the specified $node matches a regular expression where each pair of tags is separated by a single space. Use contentAfterAsTags to visualize these tags.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗺𝗮𝘁𝗰𝗵𝗔𝗳𝘁𝗲𝗿  (qr(\Af g\Z));

matchAfter2($$@)

Confirm that the string representing the tags following the specified $node matches a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space. This arrangement simplifies the regular expression used to detect combinations like p+ q? Use contentAfterAsTags2 to visualize these tags.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗺𝗮𝘁𝗰𝗵𝗔𝗳𝘁𝗲𝗿𝟮 (qr(\A f  g \Z));

matchBefore($$@)

Confirm that the string representing the tags preceding the specified $node matches a regular expression where each pair of tags is separated by a single space. Use contentBeforeAsTags to visualize these tags.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗺𝗮𝘁𝗰𝗵𝗕𝗲𝗳𝗼𝗿𝗲 (qr(\Ac d\Z));

matchBefore2($$@)

Confirm that the string representing the tags preceding the specified $node matches a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space. This arrangement simplifies the regular expression used to detect combinations like p+ q? Use contentBeforeAsTags2 to visualize these tags.

     Parameter  Description
  1  $node      Node
  2  $re        Regular expression
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗺𝗮𝘁𝗰𝗵𝗕𝗲𝗳𝗼𝗿𝗲𝟮(qr(\A c  d \Z));

path($)

Return a list representing the path to a node from the root of the parse tree which can then be reused by go to retrieve the node as long as the structure of the parse tree has not changed along the path.

     Parameter  Description
  1  $node      Node.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    is_deeply [$x->go(qw(b d 1 e))->𝗽𝗮𝘁𝗵], [qw(b d 1 e)];

    $x->by(sub {ok $x->go($_->𝗽𝗮𝘁𝗵) == $_});

pathString($)

Return a string representing the path to the specified $node from the root of the parse tree.

     Parameter  Description
  1  $node      Node.

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

    ok $a->findByNumber(9)->𝗽𝗮𝘁𝗵𝗦𝘁𝗿𝗶𝗻𝗴 eq 'b c 1 d e';

Prev At Next

Locate adjacent nodes that match horizontally and vertically

an($$@)

Return the next node if the specified $node has the specified tag and the next node is in the specified context.

     Parameter  Description
  1  $node      Node
  2  $tag       Tag node must match
  3  @context   Optional context of the next node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $e == $d->an_d_e_b_a;

    ok  $f == $e->an_e;

    ok !$f->an_f;

ap($$@)

Return the previous node if the specified $node has the specified tag and the previous node is in the specified context.

     Parameter  Description
  1  $node      Node
  2  $tag       Tag node must match
  3  @context   Optional context of the previous node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $c == $d->ap_d_c_b_a;

    ok  $c == $d->ap_d;

    ok !$c->ap_c;

apn($$$@)

Return (previous node, next node) if the previous and current nodes have the specified tags and the next node is in the specified context else return ().

     Parameter  Description
  1  $node      Current node
  2  $prev      Tag for the previous node
  3  $tag       Tag for specified node
  4  @context   Context for the next node.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    is_deeply[$c, $e], [$d->apn_c_d_e_b_a];

matchesNextTags($@)

Return the specified b<$node> if the siblings following the specified $node match the specified <@tags> else return undef.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/><d/><e/><f/></b></a>
  END

    ok  -t $a->first__first__matchesNextTags_d_e eq q(c);
    ok  -t $a->first__first__mnt_d_e             eq q(c);
    ok    !$a->       first__matchesNextTags_d_e;
    ok  -t $a->  last->last__matchesPrevTags_e_d eq q(f);
    ok  -t $a->  last->last__mpt_e_d             eq q(f);
    ok    !$a->        last__matchesPrevTags_e_d;
   }

mnt is a synonym for matchesNextTags.

matchesPrevTags($@)

Return the specified b<$node> if the siblings prior to the specified $node match the specified <@tags> else return undef.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/><d/><e/><f/></b></a>
  END

    ok  -t $a->first__first__matchesNextTags_d_e eq q(c);
    ok  -t $a->first__first__mnt_d_e             eq q(c);
    ok    !$a->       first__matchesNextTags_d_e;
    ok  -t $a->  last->last__matchesPrevTags_e_d eq q(f);
    ok  -t $a->  last->last__mpt_e_d             eq q(f);
    ok    !$a->        last__matchesPrevTags_e_d;
   }

mpt is a synonym for matchesPrevTags.

Child of, Parent of, Sibling of

Nodes that are directly above, below or adjacent to another node.

parentOf($$@)

Returns the specified $parent node if it is the parent of the specified $child node and the $parent node is in the specified optional context.

     Parameter  Description
  1  $parent    Parent
  2  $child     Child
  3  @context   Optional context

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    ok $e->𝗽𝗮𝗿𝗲𝗻𝘁𝗢𝗳($j);

childOf($$@)

Returns the specified $child node if it is a child of the specified $parent node and the $child node is in the specified optional context.

     Parameter  Description
  1  $child     Child
  2  $parent    Parent
  3  @context   Optional context

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    ok $j->𝗰𝗵𝗶𝗹𝗱𝗢𝗳($e);

succeedingSiblingOf($$@)

Returns the specified $child node if it has the same parent as $sibling and occurs after $sibling and has the optionally specified context else returns undef.

     Parameter  Description
  1  $child     Child
  2  $sibling   Sibling thought to occur before child
  3  @context   Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
    <e/>
   </b>
   <B>
    <C/>
    <D/>
    <E/>
   </B>
  </a>
  END

    my ($c, $d, $e, $b, $C, $D, $B) = $a->byList;
    ok !$e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($e);
    ok  $e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($d);
    ok  $e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($c);
    ok !$e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($b);
    ok !$e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($B);
    ok !$e->𝘀𝘂𝗰𝗰𝗲𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($C);

    ok !$c->precedingSiblingOf($c);
    ok  $c->precedingSiblingOf($d);
    ok  $c->precedingSiblingOf($e);
    ok !$c->precedingSiblingOf($b);
    ok !$c->precedingSiblingOf($B);
    ok !$c->precedingSiblingOf($C);
   }

precedingSiblingOf($$@)

Returns the specified $child node if it has the same parent as $sibling and occurs before $sibling and has the optionally specified context else returns undef.

     Parameter  Description
  1  $child     Child
  2  $sibling   Sibling thought to occur after child
  3  @context   Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
    <d/>
    <e/>
   </b>
   <B>
    <C/>
    <D/>
    <E/>
   </B>
  </a>
  END

    my ($c, $d, $e, $b, $C, $D, $B) = $a->byList;
    ok !$e->succeedingSiblingOf($e);
    ok  $e->succeedingSiblingOf($d);
    ok  $e->succeedingSiblingOf($c);
    ok !$e->succeedingSiblingOf($b);
    ok !$e->succeedingSiblingOf($B);
    ok !$e->succeedingSiblingOf($C);

    ok !$c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($c);
    ok  $c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($d);
    ok  $c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($e);
    ok !$c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($b);
    ok !$c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($B);
    ok !$c->𝗽𝗿𝗲𝗰𝗲𝗱𝗶𝗻𝗴𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝗢𝗳($C);
   }

Navigation

Move around in the parse tree.

go($@)

Return the node reached from the specified $node via the specified path: (index position?)* where index is the tag of the next node to be chosen and position is the optional zero based position within the index of those tags under the current node. Position defaults to zero if not specified. Position can also be negative to index back from the top of the index array. * can be used as the last position to retrieve all nodes with the final tag.

     Parameter  Description
  1  $node      Node
  2  @path      Search specification.

Example:

   {my $x = Data::Edit::Xml::new(my $s = <<END);
  <aa>
    <a>
      <b/>
        <c id="1"/><c id="2"/><c id="3"/><c id="4"/>
      <d/>
    </a>
  </aa>
  END

    ok $x->𝗴𝗼(qw(a c))   ->id == 1;

    ok $x->𝗴𝗼(qw(a c -2))->id == 3;

    ok $x->𝗴𝗼(qw(a c *)) == 4;

    ok 1234 == join '', map {$_->id} $x->𝗴𝗼(qw(a c *));

c($$)

Return an array of all the nodes with the specified tag below the specified $node. This method is deprecated in favor of applying grep to contents.

     Parameter  Description
  1  $node      Node
  2  $tag       Tag.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b id="b1"><𝗰 id="1"/></b>
    <d id="d1"><𝗰 id="2"/></d>
    <e id="e1"><𝗰 id="3"/></e>
    <b id="b2"><𝗰 id="4"/></b>
    <d id="d2"><𝗰 id="5"/></d>
    <e id="e2"><𝗰 id="6"/></e>
  </a>
  END

    is_deeply [map{-u $_} $x->𝗰(q(d))],  [qw(d1 d2)];

findById($$)

Find a node in the parse tree under the specified $node with the specified $id.

     Parameter  Description
  1  $node      Parse tree
  2  $id        Id desired.

Example:

    ok -p $a eq <<END;
  <a id="i1">
    <b id="i2"/>
    <c id="i3"/>
    <B id="i4">
      <c id="i5"/>
    </B>
    <c id="i6"/>
    <b id="i7"/>
  </a>
  END

    ok -t $a->findById_i4 eq q(B);

    ok -t $a->findById_i5 eq q(c);

matchesNode($$@)

Return the $first node if it matches the $second node's tag and the specified @attributes else return undef.

     Parameter    Description
  1  $first       First node
  2  $second      Second node
  3  @attributes  Attributes to match on

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a       id="1">
    <b     id="2"   name="b">
      <c   id="3"   name="c"/>
    </b>
    <c     id="4">
      <b   id="5"   name="b">
        <c id="6"   name="c"/>
      </b>
    </c>
  </a>
  END

    my ($c, $b, $C, $B) = $a->byList;
    ok  $b->id == 2;
    ok  $c->id == 3;
    ok  $B->id == 5;
    ok  $C->id == 6;
    ok  $c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗡𝗼𝗱𝗲($C, qw(name));
    ok !$c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗡𝗼𝗱𝗲($C, qw(id name));
    ok  $c->matchesSubTree($C, qw(name));
    ok  $b->matchesSubTree($B, qw(name));
    ok !$c->matchesSubTree($C, qw(id name));
    ok !$b->matchesSubTree($C, qw(name));

    is_deeply [$a->findMatchingSubTrees($b, qw(name))], [$b, $B];
    is_deeply [$a->findMatchingSubTrees($c, qw(name))], [$c, $C];
    is_deeply [$a->findMatchingSubTrees(new(q(<c/>)))], [$c, $C];
    is_deeply [$a->findMatchingSubTrees(new(q(<b><c/></b>)))], [$b, $B];
    is_deeply [$a->findMatchingSubTrees(new(q(<b id="2"><c id="3"/></b>)), q(id))], [$b];
   }

matchesSubTree($$@)

Return the $first node if it matches the $second node and the nodes under the first node match the corresponding nodes under the second node, else return undef.

     Parameter    Description
  1  $first       First node
  2  $second      Second node
  3  @attributes  Attributes to match on

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a       id="1">
    <b     id="2"   name="b">
      <c   id="3"   name="c"/>
    </b>
    <c     id="4">
      <b   id="5"   name="b">
        <c id="6"   name="c"/>
      </b>
    </c>
  </a>
  END

    my ($c, $b, $C, $B) = $a->byList;
    ok  $b->id == 2;
    ok  $c->id == 3;
    ok  $B->id == 5;
    ok  $C->id == 6;
    ok  $c->matchesNode($C, qw(name));
    ok !$c->matchesNode($C, qw(id name));
    ok  $c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗦𝘂𝗯𝗧𝗿𝗲𝗲($C, qw(name));
    ok  $b->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗦𝘂𝗯𝗧𝗿𝗲𝗲($B, qw(name));
    ok !$c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗦𝘂𝗯𝗧𝗿𝗲𝗲($C, qw(id name));
    ok !$b->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗦𝘂𝗯𝗧𝗿𝗲𝗲($C, qw(name));

    is_deeply [$a->findMatchingSubTrees($b, qw(name))], [$b, $B];
    is_deeply [$a->findMatchingSubTrees($c, qw(name))], [$c, $C];
    is_deeply [$a->findMatchingSubTrees(new(q(<c/>)))], [$c, $C];
    is_deeply [$a->findMatchingSubTrees(new(q(<b><c/></b>)))], [$b, $B];
    is_deeply [$a->findMatchingSubTrees(new(q(<b id="2"><c id="3"/></b>)), q(id))], [$b];
   }

findMatchingSubTrees($$@)

Find nodes in the parse tree whose sub tree matches the specified $subTree excluding any of the specified $attributes.

     Parameter    Description
  1  $node        Parse tree
  2  $subTree     Parse tree to match
  3  @attributes  Attributes to match on

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a       id="1">
    <b     id="2"   name="b">
      <c   id="3"   name="c"/>
    </b>
    <c     id="4">
      <b   id="5"   name="b">
        <c id="6"   name="c"/>
      </b>
    </c>
  </a>
  END

    my ($c, $b, $C, $B) = $a->byList;
    ok  $b->id == 2;
    ok  $c->id == 3;
    ok  $B->id == 5;
    ok  $C->id == 6;
    ok  $c->matchesNode($C, qw(name));
    ok !$c->matchesNode($C, qw(id name));
    ok  $c->matchesSubTree($C, qw(name));
    ok  $b->matchesSubTree($B, qw(name));
    ok !$c->matchesSubTree($C, qw(id name));
    ok !$b->matchesSubTree($C, qw(name));

    is_deeply [$a->𝗳𝗶𝗻𝗱𝗠𝗮𝘁𝗰𝗵𝗶𝗻𝗴𝗦𝘂𝗯𝗧𝗿𝗲𝗲𝘀($b, qw(name))], [$b, $B];
    is_deeply [$a->𝗳𝗶𝗻𝗱𝗠𝗮𝘁𝗰𝗵𝗶𝗻𝗴𝗦𝘂𝗯𝗧𝗿𝗲𝗲𝘀($c, qw(name))], [$c, $C];
    is_deeply [$a->𝗳𝗶𝗻𝗱𝗠𝗮𝘁𝗰𝗵𝗶𝗻𝗴𝗦𝘂𝗯𝗧𝗿𝗲𝗲𝘀(new(q(<c/>)))], [$c, $C];
    is_deeply [$a->𝗳𝗶𝗻𝗱𝗠𝗮𝘁𝗰𝗵𝗶𝗻𝗴𝗦𝘂𝗯𝗧𝗿𝗲𝗲𝘀(new(q(<b><c/></b>)))], [$b, $B];
    is_deeply [$a->𝗳𝗶𝗻𝗱𝗠𝗮𝘁𝗰𝗵𝗶𝗻𝗴𝗦𝘂𝗯𝗧𝗿𝗲𝗲𝘀(new(q(<b id="2"><c id="3"/></b>)), q(id))], [$b];
   }

First

Find nodes that are first amongst their siblings.

first($@)

Return the first node below the specified $node optionally checking the first node's context. See addFirst to ensure that an expected node is in position.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use firstNonBlank to skip a (rare) initial blank text CDATA. Use firstNonBlankX to die rather then receive a returned undef or false result.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(q(b))->𝗳𝗶𝗿𝘀𝘁->id == 13;

    ok  $a->go(q(b))->𝗳𝗶𝗿𝘀𝘁(qw(c b a));

    ok !$a->go(q(b))->𝗳𝗶𝗿𝘀𝘁(qw(b a));

firstn($$@)

Return the $n'th first node below the specified $node optionally checking its context or undef if there is no such node. firstn(1) is identical in effect to first.

     Parameter  Description
  1  $node      Node
  2  $N         Number of times to go first
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d/><e/><f/></c></b></a>
  END
    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
        <e/>
        <f/>
      </c>
    </b>
  </a>
  END
    ok  -t $a->firstn_0 eq q(a);
    ok  -t $a->firstn_1 eq q(b);
    ok  -t $a->firstn_2 eq q(c);
    ok  -t $a->firstn_3 eq q(d);

    ok  -t $a->firstn_3__nextn_0 eq q(d);
    ok  -t $a->firstn_3__nextn_1 eq q(e);
    ok  -t $a->firstn_3__nextn_2 eq q(f);
   }

firstText($@)

Return the first node under the specified $node if it is in the optional and it is a text node otherwise undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new("<a>AA<b/>BB<c/>CC<d/><e/><f/>DD<g/>HH</a>");
    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END
    ok  $a->firstText_a__text eq q(AA);
    ok !$a->go_c__firstText_c_a;
    ok !$a->go_c__firstText_c_b;
    ok  $a->lastText__text eq q(HH);
    ok  $a->lastText_a__text eq q(HH);
    ok !$a->go_c__lastText;
    ok  $a->go_c__nextText_c_a__text eq q(CC);
    ok !$a->go_e__nextText;
    ok  $a->go_c__prevText_c__text eq q(BB);
    ok !$a->go_e__prevText;
   }

    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END

firstTextMatches($$@)

Return the first node under the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context. Else return undef.

     Parameter  Description
  1  $node      Node
  2  $match     Regular expression the text must match
  3  @context   Optional context of specified node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb<c>cc</c>BB
    </b>
  </a>
  END

    my ($bb, $cc, $c, $BB, $b) = $a->byList;

    ok $bb->matchesText(qr(bb));

    ok $b->at_b_a &&  $b->𝗳𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb));

    ok                $b->𝗳𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb), qw(b a));

    ok $c->at_c_b &&  $c->𝗳𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(cc));

    ok $c->at_c_b && !$c->𝗳𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb));

firstBy($@)

Return a list of the first instance of each specified tag encountered in a post-order traversal from the specified $node or a hash of all first instances if no tags are specified.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

     {my %f = $a->𝗳𝗶𝗿𝘀𝘁𝗕𝘆;

      ok $f{b}->id == 12;

firstDown($@)

Return a list of the first instance of each specified tag encountered in a pre-order traversal from the specified $node or a hash of all first instances if no tags are specified.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

     {my %f = $a->𝗳𝗶𝗿𝘀𝘁𝗗𝗼𝘄𝗻;

      ok $f{b}->id == 15;

firstIn($@)

Return the first child node matching one of the named tags under the specified parent node.

     Parameter  Description
  1  $node      Parent node
  2  @tags      Child tags to search for.

Example:

    ok $a->prettyStringCDATA eq <<'END';
  <a><CDATA> </CDATA>
      <A/>
  <CDATA>  </CDATA>
      <C/>
  <CDATA>  </CDATA>
      <E/>
  <CDATA>  </CDATA>
      <G/>
  <CDATA>  </CDATA>
  </a>
  END

    ok $a->𝗳𝗶𝗿𝘀𝘁𝗜𝗻(qw(b B c C))->tag eq qq(C);

firstNot($@)

Return the first child node that does not match any of the named @tags under the specified parent $node. Return undef if there is no such child node.

     Parameter  Description
  1  $node      Parent node
  2  @tags      Child tags to avoid.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $c == $a->firstNot_a_b;

firstInIndex($@)

Return the specified $node if it is first in its index and optionally at the specified context else undef

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

    ok  $a->findByNumber (5)->𝗳𝗶𝗿𝘀𝘁𝗜𝗻𝗜𝗻𝗱𝗲𝘅;

    ok !$a->findByNumber(7) ->𝗳𝗶𝗿𝘀𝘁𝗜𝗻𝗜𝗻𝗱𝗲𝘅;

firstOf($@)

Return an array of the nodes that are continuously first under their specified parent node and that match the specified list of tags.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/><d/><d/><e/><d/><d/><c/></b></a>
  END

    is_deeply [qw(c d d)], [map {-t $_} $a->go(q(b))->𝗳𝗶𝗿𝘀𝘁𝗢𝗳(qw(c d))];

firstWhile($@)

Go first from the specified $node and continue deeper firstly as long as each first child node matches one of the specified @tags. Return the deepest such node encountered or else return undef if no such node is encountered.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e><f/>
  </e></d></c></b>
  <B><C><D><E><F/>
  </E></D></C></B></a>
  END

    my ($f, $e, $d, $c, $b, $F, $E, $D, $C, $B) = $a->byList;

    if (1)

firstUntil($@)

Go first from the specified $node and continue deeper firstly until a first child node matches the specified @context or return undef if there is no such node. Return the first child of the specified $node if no @context is specified.

     Parameter  Description
  1  $node      Node
  2  @context   Context to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e><f/>
  </e></d></c></b>
  <B><C><D><E><F/>
  </E></D></C></B></a>
  END

    my ($f, $e, $d, $c, $b, $F, $E, $D, $C, $B) = $a->byList;

    if (1)

firstUntilText($@)

Go first from the specified $node and continue deeper firstly until a text node is encountered whose parent matches the specified @context or return undef if there is no such node.

     Parameter  Description
  1  $node      Node
  2  @context   Context to search for.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      cccc
      <d/>
      <e/>
    </b>
    <f>
      <g/>
      hhhh
      <i/>
    </f>
    <j>
      <k/>
      <l/>
      mmmm
    </j>
  </a>
  END

    ok $a->𝗳𝗶𝗿𝘀𝘁𝗨𝗻𝘁𝗶𝗹𝗧𝗲𝘅𝘁->text =~ m(cccc)s;
    ok $a->lastUntilText ->text =~ m(mmmm)s;

   }

firstContextOf($@)

Return the first node encountered in the specified context in a depth first post-order traversal of the parse tree.

     Parameter  Description
  1  $node      Node
  2  @context   Array of tags specifying context.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a        id="a1">
    <b1     id="b1">
       <c   id="c1">
         <d id="d1">DD11</d>
         <e id="e1">EE11</e>
      </c>
    </b1>
    <b2     id="b2">
       <c   id="c2">
         <d id="d2">DD22</d>
         <e id="e2">EE22</e>
      </c>
    </b2>
    <b3     id="b3">
       <c   id="c3">
         <d id="d3">DD33</d>
         <e id="e3">EE33</e>
      </c>
    </b3>
  </a>
  END

    ok $x->𝗳𝗶𝗿𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(d c))         ->id     eq qq(d1);

    ok $x->𝗳𝗶𝗿𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(e c b2))      ->id     eq qq(e2);

    ok $x->𝗳𝗶𝗿𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(CDATA d c b2))->string eq qq(DD22);

firstSibling($@)

Return the first sibling of the specified $node in the optional context else undef

     Parameter  Description
  1  $node      Node
  2  @context   Array of tags specifying context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(qw(b b))->𝗳𝗶𝗿𝘀𝘁𝗦𝗶𝗯𝗹𝗶𝗻𝗴->id == 13;

Last

Find nodes that are last amongst their siblings.

last($@)

Return the last node below the specified $node optionally checking the last node's context. See addLast to ensure that an expected node is in position.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use lastNonBlank to skip a (rare) initial blank text CDATA. Use lastNonBlankX to die rather then receive a returned undef or false result.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(q(b))->𝗹𝗮𝘀𝘁 ->id == 22;

    ok  $a->go(q(b))->𝗹𝗮𝘀𝘁(qw(g b a));

    ok !$a->go(q(b))->𝗹𝗮𝘀𝘁(qw(b a));

    ok !$a->go(q(b))->𝗹𝗮𝘀𝘁(qw(b a));

lastn($$@)

Return the $n'th last node below the specified $node optionally checking its context or undef if there is no such node. lastn(1) is identical in effect to last.

     Parameter  Description
  1  $node      Node
  2  $N         Number of times to go last
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d/><e/><f/></c></b>
     <B><C><D/><E/><F/></C></B></a>
  END
    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
        <e/>
        <f/>
      </c>
    </b>
    <B>
      <C>
        <D/>
        <E/>
        <F/>
      </C>
    </B>
  </a>
  END

    ok  -t $a->lastn_0 eq q(a);
    ok  -t $a->lastn_1 eq q(B);
    ok  -t $a->lastn_2 eq q(C);
    ok  -t $a->lastn_3 eq q(F);

    ok  -t $a->lastn_3__prevn_0 eq q(F);
    ok  -t $a->lastn_3__prevn_1 eq q(E);
    ok  -t $a->lastn_3__prevn_2 eq q(D);
   }

lastText($@)

Return the last node under the specified $node if it is in the optional and it is a text node otherwise undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new("<a>AA<b/>BB<c/>CC<d/><e/><f/>DD<g/>HH</a>");
    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END
    ok  $a->firstText_a__text eq q(AA);
    ok !$a->go_c__firstText_c_a;
    ok !$a->go_c__firstText_c_b;
    ok  $a->lastText__text eq q(HH);
    ok  $a->lastText_a__text eq q(HH);
    ok !$a->go_c__lastText;
    ok  $a->go_c__nextText_c_a__text eq q(CC);
    ok !$a->go_e__nextText;
    ok  $a->go_c__prevText_c__text eq q(BB);
    ok !$a->go_e__prevText;
   }

    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END

lastTextMatches($$@)

Return the last node under the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context. Else return undef.

     Parameter  Description
  1  $node      Node
  2  $match     Regular expression the text must match
  3  @context   Optional context of specified  node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb<c>cc</c>BB
    </b>
  </a>
  END

    my ($bb, $cc, $c, $BB, $b) = $a->byList;

    ok $BB->matchesText(qr(BB));

    ok $b->at_b_a &&  $b->𝗹𝗮𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(BB));

    ok                $b->𝗹𝗮𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(BB), qw(b a));

    ok $c->at_c_b &&  $c->𝗹𝗮𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(cc));

    ok $c->at_c_b && !$c->𝗹𝗮𝘀𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb));

lastBy($@)

Return a list of the last instance of each specified tag encountered in a post-order traversal from the specified $node or a hash of all last instances if no tags are specified.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

     {my %l = $a->𝗹𝗮𝘀𝘁𝗕𝘆;

      ok $l{b}->id == 23;

lastDown($@)

Return a list of the last instance of each specified tag encountered in a pre-order traversal from the specified $node or a hash of all last instances if no tags are specified.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

     {my %l = $a->𝗹𝗮𝘀𝘁𝗗𝗼𝘄𝗻;

      ok $l{b}->id == 26;

lastIn($@)

Return the last child node matching one of the named tags under the specified parent node.

     Parameter  Description
  1  $node      Parent node
  2  @tags      Child tags to search for.

Example:

    ok $a->prettyStringCDATA eq <<'END';
  <a><CDATA> </CDATA>
      <A/>
  <CDATA>  </CDATA>
      <C/>
  <CDATA>  </CDATA>
      <E/>
  <CDATA>  </CDATA>
      <G/>
  <CDATA>  </CDATA>
  </a>
  END

    ok $a->𝗹𝗮𝘀𝘁𝗜𝗻(qw(e E f F))->tag eq qq(E);

lastNot($@)

Return the last child node that does not match any of the named @tags under the specified parent $node. Return undef if there is no such child node.

     Parameter  Description
  1  $node      Parent node
  2  @tags      Child tags to avoid.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $d == $a->lastNot_e_f;

lastOf($@)

Return an array of the nodes that are continuously last under their specified parent node and that match the specified list of tags.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/><d/><d/><e/><d/><d/><c/></b></a>
  END

    is_deeply [qw(d d c)], [map {-t $_} $a->go(q(b))->𝗹𝗮𝘀𝘁𝗢𝗳 (qw(c d))];

lastInIndex($@)

Return the specified $node if it is last in its index and optionally at the specified context else undef

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

    ok  $a->findByNumber(10)->𝗹𝗮𝘀𝘁𝗜𝗻𝗜𝗻𝗱𝗲𝘅;

    ok !$a->findByNumber(7) ->𝗹𝗮𝘀𝘁𝗜𝗻𝗜𝗻𝗱𝗲𝘅;

lastContextOf($@)

Return the last node encountered in the specified context in a depth first reverse pre-order traversal of the parse tree.

     Parameter  Description
  1  $node      Node
  2  @context   Array of tags specifying context.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a        id="a1">
    <b1     id="b1">
       <c   id="c1">
         <d id="d1">DD11</d>
         <e id="e1">EE11</e>
      </c>
    </b1>
    <b2     id="b2">
       <c   id="c2">
         <d id="d2">DD22</d>
         <e id="e2">EE22</e>
      </c>
    </b2>
    <b3     id="b3">
       <c   id="c3">
         <d id="d3">DD33</d>
         <e id="e3">EE33</e>
      </c>
    </b3>
  </a>
  END

    ok $x-> 𝗹𝗮𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(d c))         ->id     eq qq(d3);

    ok $x-> 𝗹𝗮𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(e c b2     )) ->id     eq qq(e2);

    ok $x-> 𝗹𝗮𝘀𝘁𝗖𝗼𝗻𝘁𝗲𝘅𝘁𝗢𝗳(qw(CDATA e c b2))->string eq qq(EE22);

lastSibling($@)

Return the last sibling of the specified $node in the optional context else undef

     Parameter  Description
  1  $node      Node
  2  @context   Array of tags specifying context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(qw(b b))->𝗹𝗮𝘀𝘁𝗦𝗶𝗯𝗹𝗶𝗻𝗴 ->id == 22;

lastWhile($@)

Go last from the specified $node and continue deeper lastly as long as each last child node matches one of the specified @tags. Return the deepest such node encountered or else return undef if no such node is encountered.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e><f/>
  </e></d></c></b>
  <B><C><D><E><F/>
  </E></D></C></B></a>
  END

    my ($f, $e, $d, $c, $b, $F, $E, $D, $C, $B) = $a->byList;

    if (1)

lastUntil($@)

Go last from the specified $node and continue deeper lastly until a last child node matches the specified @context or return undef if there is no such node. Return the last child of the specified $node if no @context is specified.

     Parameter  Description
  1  $node      Node
  2  @context   Context to search for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e><f/>
  </e></d></c></b>
  <B><C><D><E><F/>
  </E></D></C></B></a>
  END

    my ($f, $e, $d, $c, $b, $F, $E, $D, $C, $B) = $a->byList;

    if (1)

lastUntilText($@)

Go last from the specified $node and continue deeper lastly until a last child text node matches the specified @context or return undef if there is no such node.

     Parameter  Description
  1  $node      Node
  2  @context   Context to search for.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      cccc
      <d/>
      <e/>
    </b>
    <f>
      <g/>
      hhhh
      <i/>
    </f>
    <j>
      <k/>
      <l/>
      mmmm
    </j>
  </a>
  END

    ok $a->firstUntilText->text =~ m(cccc)s;
    ok $a->𝗹𝗮𝘀𝘁𝗨𝗻𝘁𝗶𝗹𝗧𝗲𝘅𝘁 ->text =~ m(mmmm)s;

   }

Next

Find sibling nodes after the specified $node.

next($@)

Return the node next to the specified $node, optionally checking the next node's context. See addNext to ensure that an expected node is in position.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use nextNonBlank to skip a (rare) initial blank text CDATA. Use nextNonBlankX to die rather then receive a returned undef or false result.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(qw(b b e))->𝗻𝗲𝘅𝘁 ->id == 19;

    ok  $a->go(qw(b b e))->𝗻𝗲𝘅𝘁(qw(f b b a));

    ok !$a->go(qw(b b e))->𝗻𝗲𝘅𝘁(qw(f b a));

nextn($$@)

Return the $n'th next node after the specified $node optionally checking its context or undef if there is no such node. nextn(1) is identical in effect to next.

     Parameter  Description
  1  $node      Node
  2  $N         Number of times to go next
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d/><e/><f/></c></b></a>
  END
    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
        <e/>
        <f/>
      </c>
    </b>
  </a>
  END
    ok  -t $a->firstn_0 eq q(a);
    ok  -t $a->firstn_1 eq q(b);
    ok  -t $a->firstn_2 eq q(c);
    ok  -t $a->firstn_3 eq q(d);

    ok  -t $a->firstn_3__nextn_0 eq q(d);
    ok  -t $a->firstn_3__nextn_1 eq q(e);
    ok  -t $a->firstn_3__nextn_2 eq q(f);
   }

nextText($@)

Return the node after the specified $node if it is in the optional and it is a text node otherwise undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new("<a>AA<b/>BB<c/>CC<d/><e/><f/>DD<g/>HH</a>");
    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END
    ok  $a->firstText_a__text eq q(AA);
    ok !$a->go_c__firstText_c_a;
    ok !$a->go_c__firstText_c_b;
    ok  $a->lastText__text eq q(HH);
    ok  $a->lastText_a__text eq q(HH);
    ok !$a->go_c__lastText;
    ok  $a->go_c__nextText_c_a__text eq q(CC);
    ok !$a->go_e__nextText;
    ok  $a->go_c__prevText_c__text eq q(BB);
    ok !$a->go_e__prevText;
   }

    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END

nextTextMatches($$@)

Return the next node to the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context. Else return undef.

     Parameter  Description
  1  $node      Node
  2  $match     Regular expression the text must match
  3  @context   Optional context of specified node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb<c>cc</c>BB
    </b>
  </a>
  END

    ok $cc->matchesText(qr(cc));

    ok $c->at_c_b &&  $c->𝗻𝗲𝘅𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(BB));

    ok $b->at_b   && !$b->𝗻𝗲𝘅𝘁𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(BB));

nextIn($@)

Return the nearest sibling after the specified $node that matches one of the named tags or undef if there is no such sibling node.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

    ok $a->prettyStringCDATA eq <<'END';
  <a><CDATA> </CDATA>
      <A/>
  <CDATA>  </CDATA>
      <C/>
  <CDATA>  </CDATA>
      <E/>
  <CDATA>  </CDATA>
      <G/>
  <CDATA>  </CDATA>
  </a>
  END

    ok $a->firstIn(qw(b B c C))->𝗻𝗲𝘅𝘁𝗜𝗻(qw(A G))->tag eq qq(G);

nextOn($@)

Step forwards as far as possible from the specified $node while remaining on nodes with the specified tags. In scalar context return the last such node reached or the starting node if no such steps are possible. In array context return the start node and any following matching nodes.

     Parameter  Description
  1  $node      Start node
  2  @tags      Tags identifying nodes that can be step on to context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="1"/>
      <d id="2"/>
      <c id="3"/>
      <d id="4"/>
      <e id="5"/>
    </b>
  </a>
  END

    ok $c->id == 1;

    ok $e->id == 5;

    ok $c->𝗻𝗲𝘅𝘁𝗢𝗻(qw(d))  ->id == 2;

    ok $c->𝗻𝗲𝘅𝘁𝗢𝗻(qw(c d))->id == 4;

    ok $e->𝗻𝗲𝘅𝘁𝗢𝗻(qw(c d))     == $e;

nextWhile($@)

Go to the next sibling of the specified $node and continue forwards while the tag of each sibling node matches one of the specified @tags. Return the first sibling node that does not match else undef if there is no such sibling.

     Parameter  Description
  1  $node      Node
  2  @tags      Child tags to avoid.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $e == $b->nextWhile_c_d;

    ok $c == $b->𝗻𝗲𝘅𝘁𝗪𝗵𝗶𝗹𝗲;

nextUntil($@)

Go to the next sibling of the specified $node and continue forwards until the tag of a sibling node matches one of the specified @tags. Return the matching sibling node else undef if there is no such sibling node.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to look for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $e == $b->nextUntil_e_f;

    ok      !$b->𝗻𝗲𝘅𝘁𝗨𝗻𝘁𝗶𝗹;

Prev

Find sibling nodes before the specified $node.

prev($@)

Return the node before the specified $node, optionally checking the previous node's context. See addLast to ensure that an expected node is in position.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Use prevNonBlank to skip a (rare) initial blank text CDATA. Use prevNonBlankX to die rather then receive a returned undef or false result.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok  $a->go(qw(b b e))->𝗽𝗿𝗲𝘃 ->id == 17;

    ok  $a->go(qw(b b e))->𝗽𝗿𝗲𝘃(qw(d b b a));

    ok !$a->go(qw(b b e))->𝗽𝗿𝗲𝘃(qw(d b a));

prevText($@)

Return the node before the specified $node if it is in the optional and it is a text node otherwise undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new("<a>AA<b/>BB<c/>CC<d/><e/><f/>DD<g/>HH</a>");
    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END
    ok  $a->firstText_a__text eq q(AA);
    ok !$a->go_c__firstText_c_a;
    ok !$a->go_c__firstText_c_b;
    ok  $a->lastText__text eq q(HH);
    ok  $a->lastText_a__text eq q(HH);
    ok !$a->go_c__lastText;
    ok  $a->go_c__nextText_c_a__text eq q(CC);
    ok !$a->go_e__nextText;
    ok  $a->go_c__prevText_c__text eq q(BB);
    ok !$a->go_e__prevText;
   }

    ok -p $a eq <<END;
  <a>AA
    <b/>
  BB
    <c/>
  CC
    <d/>
    <e/>
    <f/>
  DD
    <g/>
  HH
  </a>
  END

prevn($$@)

Return the $n'th previous node after the specified $node optionally checking its context or undef if there is no such node. prevn(1) is identical in effect to prev.

     Parameter  Description
  1  $node      Node
  2  $N         Number of times to go prev
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d/><e/><f/></c></b>
     <B><C><D/><E/><F/></C></B></a>
  END
    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
        <e/>
        <f/>
      </c>
    </b>
    <B>
      <C>
        <D/>
        <E/>
        <F/>
      </C>
    </B>
  </a>
  END

    ok  -t $a->lastn_0 eq q(a);
    ok  -t $a->lastn_1 eq q(B);
    ok  -t $a->lastn_2 eq q(C);
    ok  -t $a->lastn_3 eq q(F);

    ok  -t $a->lastn_3__prevn_0 eq q(F);
    ok  -t $a->lastn_3__prevn_1 eq q(E);
    ok  -t $a->lastn_3__prevn_2 eq q(D);
   }

prevTextMatches($$@)

Return the previous node to the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context. Else return undef.

     Parameter  Description
  1  $node      Node
  2  $match     Regular expression the text must match
  3  @context   Optional context of specified node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb<c>cc</c>BB
    </b>
  </a>
  END

    ok $cc->matchesText(qr(cc));

    ok $c->at_c_b &&  $c->𝗽𝗿𝗲𝘃𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb));

    ok $b->at_b   && !$b->𝗽𝗿𝗲𝘃𝗧𝗲𝘅𝘁𝗠𝗮𝘁𝗰𝗵𝗲𝘀(qr(bb));

prevIn($@)

Return the nearest sibling node before the specified $node which matches one of the named tags or undef if there is no such sibling node.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to search for.

Example:

    ok $a->prettyStringCDATA eq <<'END';
  <a><CDATA> </CDATA>
      <A/>
  <CDATA>  </CDATA>
      <C/>
  <CDATA>  </CDATA>
      <E/>
  <CDATA>  </CDATA>
      <G/>
  <CDATA>  </CDATA>
  </a>
  END

    ok $a->lastIn(qw(e E f F))->𝗽𝗿𝗲𝘃𝗜𝗻(qw(A G))->tag eq qq(A);

prevOn($@)

Step backwards as far as possible while remaining on nodes with the specified tags. In scalar context return the last such node reached or the starting node if no such steps are possible. In array context return the start node and any preceding matching nodes.

     Parameter  Description
  1  $node      Start node
  2  @tags      Tags identifying nodes that can be step on to context.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="1"/>
      <d id="2"/>
      <c id="3"/>
      <d id="4"/>
      <e id="5"/>
    </b>
  </a>
  END

    ok $c->id == 1;

    ok $e->id == 5;

    ok $e->𝗽𝗿𝗲𝘃𝗢𝗻(qw(d))  ->id == 4;

    ok $e->𝗽𝗿𝗲𝘃𝗢𝗻(qw(c d))     == $c;

prevWhile($@)

Go to the previous sibling of the specified $node and continue backwards while the tag of each sibling node matches one of the specified @tags. Return the first sibling node that does not match else undef if there is no such sibling.

     Parameter  Description
  1  $node      Parent node
  2  @tags      Child tags to avoid.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $c == $f->prevWhile_e_d;

    ok $b == $c->𝗽𝗿𝗲𝘃𝗪𝗵𝗶𝗹𝗲;

prevUntil($@)

Go to the previous sibling of the specified $node and continue backwards until the tag of a sibling node matches one of the specified @tags. Return the matching sibling node else undef if there is no such sibling node.

     Parameter  Description
  1  $node      Node
  2  @tags      Tags to look for.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
    <f/>
  </a>
  END

    my ($b, $c, $d, $e, $f) = $a->byList;

    ok $b == $f->prevUntil_a_b;

    ok      !$c->𝗽𝗿𝗲𝘃𝗨𝗻𝘁𝗶𝗹;

Up

Methods for moving up the parse tree from a node.

up($@)

Return the parent of the current node optionally checking the parent node's context or return undef if the specified $node is the root of the parse tree. See addWrapWith to ensure that an expected node is in position.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context of parent.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><b><b><b><b><c/></b></b></b></b></c></b></a>
  END

    $a->numberTree;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <b id="4">
          <b id="5">
            <b id="6">
              <b id="7">
                <c id="8"/>
              </b>
            </b>
          </b>
        </b>
      </c>
    </b>
  </a>
  END

    my $c = $a->findByNumber(8);
    ok -t $c eq q(c);
    ok  $c->up_b__number == 7;
    ok  $c->upn_2__number == 6;
    ok  $c->upWhile_b__number == 4;
    ok  $c->upWhile_a_b__number == 4;
    ok  $c->upWhile_b_c__number == 2;

    ok  $c->upUntil__number == 7;
    ok  $c->upUntil_b_c__number == 4;
   }

upn($$@)

Go up the specified number of levels from the specified $node and return the node reached optionally checking the parent node's context or undef if there is no such node.upn(1) is identical in effect to up. Or use ancestry to get the path back to the root node.

     Parameter  Description
  1  $node      Start node
  2  $levels    Number of levels to go up
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><b><b><b><b><c/></b></b></b></b></c></b></a>
  END

    $a->numberTree;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <b id="4">
          <b id="5">
            <b id="6">
              <b id="7">
                <c id="8"/>
              </b>
            </b>
          </b>
        </b>
      </c>
    </b>
  </a>
  END

    my $c = $a->findByNumber(8);
    ok -t $c eq q(c);
    ok  $c->up_b__number == 7;
    ok  $c->upn_2__number == 6;
    ok  $c->upWhile_b__number == 4;
    ok  $c->upWhile_a_b__number == 4;
    ok  $c->upWhile_b_c__number == 2;

    ok  $c->upUntil__number == 7;
    ok  $c->upUntil_b_c__number == 4;
   }

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e/></d></c></b></a>
  END

    my ($e, $d, $c, $b) = $a->byList;

    ok $e = $e->upn_0_e_d_c_b_a;
    ok $d = $e->upn_1_d_c_b_a;
    ok $c = $e->upn_2_c_b_a;
    ok $b = $e->upn_3_b_a;
    ok $a = $e->upn_4_a;
    ok     !$e->upn_5;

    is_deeply [$e, $d, $c, $b, $a], [$e->ancestry];
   }

   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><d><e/></d></c></b></a>
  END

    my ($e, $d, $c, $b) = $a->byList;

    ok $e = $e->upn_0_e_d_c_b_a;

    ok $d = $e->upn_1_d_c_b_a;

    ok $c = $e->upn_2_c_b_a;

    ok $b = $e->upn_3_b_a;

    ok $a = $e->upn_4_a;

    ok     !$e->upn_5;

upWhile($@)

Go up one level from the specified $node and then continue up while each node matches on of the specified <@tags>. Return the last matching node or undef if no node matched any of the specified @tags.

     Parameter  Description
  1  $node      Start node
  2  @tags      Tags to match

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><b><b><b><b><c/></b></b></b></b></c></b></a>
  END

    $a->numberTree;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <b id="4">
          <b id="5">
            <b id="6">
              <b id="7">
                <c id="8"/>
              </b>
            </b>
          </b>
        </b>
      </c>
    </b>
  </a>
  END

    my $c = $a->findByNumber(8);
    ok -t $c eq q(c);
    ok  $c->up_b__number == 7;
    ok  $c->upn_2__number == 6;
    ok  $c->upWhile_b__number == 4;
    ok  $c->upWhile_a_b__number == 4;
    ok  $c->upWhile_b_c__number == 2;

    ok  $c->upUntil__number == 7;
    ok  $c->upUntil_b_c__number == 4;
   }

upWhileFirst($@)

Move up from the specified $node as long as each node is a first node or return undef if the specified $node is not a first node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $h == $i->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

    ok  $a == $c->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

    ok !$d->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

upWhileLast($@)

Move up from the specified $node as long as each node is a last node or return undef if the specified $node is not a last node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $j == $j->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

    ok  $a == $l->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

    ok !$d->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

    ok  $i == $k->upUntilLast;

upWhileIsOnlyChild($@)

Move up from the specified $node as long as each node is an only child or return undef if the specified $node is not an only child.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $h == $i->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗜𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

    ok  $j == $j->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗜𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

    ok !$d->𝘂𝗽𝗪𝗵𝗶𝗹𝗲𝗜𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

upUntil($@)

Return the nearest ancestral node to the specified $node that matches the specified @context or undef if there is no such node. Returns the parent node of the specified $node if no @context is specified.

     Parameter  Description
  1  $node      Start node
  2  @context   Context.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c><b><b><b><b><c/></b></b></b></b></c></b></a>
  END

    $a->numberTree;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <b id="4">
          <b id="5">
            <b id="6">
              <b id="7">
                <c id="8"/>
              </b>
            </b>
          </b>
        </b>
      </c>
    </b>
  </a>
  END

    my $c = $a->findByNumber(8);
    ok -t $c eq q(c);
    ok  $c->up_b__number == 7;
    ok  $c->upn_2__number == 6;
    ok  $c->upWhile_b__number == 4;
    ok  $c->upWhile_a_b__number == 4;
    ok  $c->upWhile_b_c__number == 2;

    ok  $c->upUntil__number == 7;
    ok  $c->upUntil_b_c__number == 4;
   }

upUntilFirst($@)

Move up from the specified $node until we reach the root or a first node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $b == $d->𝘂𝗽𝗨𝗻𝘁𝗶𝗹𝗙𝗶𝗿𝘀𝘁;

upUntilLast($@)

Move up from the specified $node until we reach the root or a last node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

upUntilIsOnlyChild($@)

Move up from the specified $node until we reach the root or another only child.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $i == $k->𝘂𝗽𝗨𝗻𝘁𝗶𝗹𝗜𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱;

upThru($@)

Go up the specified path from the specified $node returning the node at the top or undef if no such node exists.

     Parameter  Description
  1  $node      Start node
  2  @tags      Tags identifying path.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d>
        <e/>
        <f/>
      </d>
    </b>
  </a>
  END

    my ($c, $e, $f, $d, $b) = $a->byList;

    ok -t $f                eq q(f);

    ok -t $f->𝘂𝗽𝗧𝗵𝗿𝘂        eq q(f);

    ok -t $f->𝘂𝗽𝗧𝗵𝗿𝘂(qw(d)) eq q(d);

    ok -t eval{$f->𝘂𝗽𝗧𝗵𝗿𝘂(qw(d))->last->prev} eq q(e);

    ok !  eval{$f->𝘂𝗽𝗧𝗵𝗿𝘂(qw(d b))->next};

down

Methods for moving down through the parse tree from a node.

downWhileFirst($@)

Move down from the specified $node as long as each lower node is a first node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $k == $g->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

    ok  $c == $a->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

    ok  $c == $c->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

    ok       !$d->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗙𝗶𝗿𝘀𝘁;

firstLeaf is a synonym for downWhileFirst.

downWhileLast($@)

Move down from the specified $node as long as each lower node is a last node.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
      <e>
        <j/>
      </e>
      <f/>
    </b>
    <g>
      <h>
        <i>
          <k/>
          <l/>
        </i>
      </h>
    </g>
  </a>
  END

    my ($c, $d, $j, $e, $f, $b, $k, $l, $i, $h, $g) = $a->byList;

    ok  $l == $a->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

    ok  $l == $g->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

    ok       !$d->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗟𝗮𝘀𝘁;

lastLeaf is a synonym for downWhileLast.

downWhileHasSingleChild($@)

Move down from the specified $node as long as it has a single child else return undef.

     Parameter  Description
  1  $node      Start node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok  $h == $g->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗛𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

    ok  $h == $h->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗛𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

    ok       !$i->𝗱𝗼𝘄𝗻𝗪𝗵𝗶𝗹𝗲𝗛𝗮𝘀𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

Editing

Edit the data in the parse tree and change the structure of the parse tree by wrapping and unwrapping nodes, by replacing nodes, by cutting and pasting nodes, by concatenating nodes, by splitting nodes, by adding new text nodes or swapping nodes.

change($$@)

Change the name of the specified $node, optionally confirming that the $node is in a specified context and return the $node.

     Parameter  Description
  1  $node      Node
  2  $name      New name
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new('<a/>');

    $a->𝗰𝗵𝗮𝗻𝗴𝗲(qq(b));

    ok -s $a eq '<b/>';

changeText($$@)

If the specified $node is a text node in the specified context then the specified sub is passed the text of the node in $_, any changes to which are recorded in the text of the $node.

Returns undef if the specified $node is not a text node in the specified optional context else it returns the result of executing the specified sub.

     Parameter  Description
  1  $node      Text node
  2  $sub       Sub
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>Hello World</a>
  END

    $a->first->𝗰𝗵𝗮𝗻𝗴𝗲𝗧𝗲𝘅𝘁(sub{s(l) (L)g});

    ok -s $a eq q(<a>HeLLo WorLd</a>);

Cut and Put

Cut and paste nodes in the parse tree.

cut($@)

Cut out the specified $node so that it can be reinserted else where in the parse tree.

     Parameter  Description
  1  $node      Node to cut out
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
  </a>
  END

      my $c = $a->go(qw(b c))->𝗰𝘂𝘁;

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb"/>
  </a>
  END

deleteContent($@)

Delete the content of the specified $node.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb<c>cc</c>BB
    </b>
  </a>
  END

    $b->𝗱𝗲𝗹𝗲𝘁𝗲𝗖𝗼𝗻𝘁𝗲𝗻𝘁;

    ok -p $a eq <<END;
  <a>
    <b/>
  </a>
  END

putFirst($$@)

Place a cut out or new node at the front of the content of the specified $node and return the new node. See addFirst to perform this operation conditionally.

     Parameter  Description
  1  $old       Original node
  2  $new       New node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
  </a>
  END

      my $c = $a->go(qw(b c))->cut;

      $a->𝗽𝘂𝘁𝗙𝗶𝗿𝘀𝘁($c);

      ok -p $a eq <<END;
  <a id="aa">
    <c id="cc"/>
    <b id="bb"/>
  </a>
  END

putFirstCut($$@)

Cut out the $second node, place it first under the $first node and return the $second node.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $c->𝗽𝘂𝘁𝗙𝗶𝗿𝘀𝘁𝗖𝘂𝘁($d, qw(c b a));

    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
  </a>
  END

putLast($$@)

Place a cut out or new node last in the content of the specified $node and return the new node. See addLast to perform this operation conditionally.

     Parameter  Description
  1  $old       Original node
  2  $new       New node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <c id="cc"/>
    <b id="bb"/>
  </a>
  END

      $a->𝗽𝘂𝘁𝗟𝗮𝘀𝘁($a->go(qw(c))->cut);

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb"/>
    <c id="cc"/>
  </a>
  END

putLastCut($$@)

Cut out the $second node, place it last under the $first node and return the $second node.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $a->𝗽𝘂𝘁𝗟𝗮𝘀𝘁𝗖𝘂𝘁($d, qw(a));

    ok -p $a eq <<END;
  <a>
    <b>
      <c/>
    </b>
    <d/>
  </a>
  END

putNext($$@)

Place a cut out or new node just after the specified $node and return the new node. See addNext to perform this operation conditionally.

     Parameter  Description
  1  $old       Original node
  2  $new       New node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb"/>
    <c id="cc"/>
  </a>
  END

      $a->go(qw(c))->𝗽𝘂𝘁𝗡𝗲𝘅𝘁($a->go(q(b))->cut);

      ok -p $a eq <<END;
  <a id="aa">
    <c id="cc"/>
    <b id="bb"/>
  </a>
  END

putNextCut($$@)

Cut out the $second node, place it after the $first node and return the $second node.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $d->𝗽𝘂𝘁𝗡𝗲𝘅𝘁𝗖𝘂𝘁($c, qw(d b a));

    ok -p $a eq <<END;
  <a>
    <b>
      <d/>
      <c/>
    </b>
  </a>
  END

putPrev($$@)

Place a cut out or new node just before the specified $node and return the new node. See addPrev to perform this operation conditionally.

     Parameter  Description
  1  $old       Original node
  2  $new       New node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <c id="cc"/>
    <b id="bb"/>
  </a>
  END

      $a->go(qw(c))->𝗽𝘂𝘁𝗣𝗿𝗲𝘃($a->go(q(b))->cut);

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb"/>
    <c id="cc"/>
  </a>
  END

putPrevCut($$@)

Cut out the $second node, place it before the $first node and return the $second node.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $c->𝗽𝘂𝘁𝗣𝗿𝗲𝘃𝗖𝘂𝘁($d, qw(c b a));

    ok -p $a eq <<END;
  <a>
    <b>
      <d/>
      <c/>
    </b>
  </a>
  END

Move

Move nodes around in the parse tree by cutting and pasting them.

moveStartFirst($@)

Move the start of a $node to contain all of its preceding siblings as children. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose start should be moved
  2  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b/>
   <c/>
   <d>
    <e/>
   </d>
  </a>
  END

    my ($b, $c, $e, $d) = $a->byList;

    $d->𝗺𝗼𝘃𝗲𝗦𝘁𝗮𝗿𝘁𝗙𝗶𝗿𝘀𝘁;
    ok -p $a, <<END;
  <a>
    <d>
      <b/>
      <c/>
      <e/>
    </b>
  </a>
  END
   }

moveStartAfter($$@)

Move the start end of a $node to just after the specified $target node assuming that the $target node is either a preceding sibling or a child of $node. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose start should be moved
  2  $to        Target node
  3  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b/>
   <c/>
   <d>
    <e/>
   </d>
  </a>
  END

    my ($b, $c, $e, $d) = $a->byList;

    $d->𝗺𝗼𝘃𝗲𝗦𝘁𝗮𝗿𝘁𝗔𝗳𝘁𝗲𝗿($b);
    ok -p $a, <<END;
  <a>
   <d>
    <b/>
    <c/>
    <e/>
   </d>
  </a>

  END

    $d->𝗺𝗼𝘃𝗲𝗦𝘁𝗮𝗿𝘁𝗔𝗳𝘁𝗲𝗿($c);
    ok -p $a, <<END;
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b/>
   <c/>
   <d>
    <e/>
   </d>
  </a>
  END
   }

moveStartBefore($$@)

Move the start of a $node to just before the specified $target node assuming that the $target node is either a preceding sibling or a child of $node. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose start should be moved
  2  $to        Target node
  3  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b/>
   <c/>
   <d>
    <e/>
   </d>
  </a>
  END

    my ($b, $c, $e, $d) = $a->byList;

    $d->𝗺𝗼𝘃𝗲𝗦𝘁𝗮𝗿𝘁𝗕𝗲𝗳𝗼𝗿𝗲($c);
    ok -p $a, <<END;
  <a>
    <b>
    <d>
      <c/>
      <e/>
    </d>
    <e/>
  </a>
  END

    $d->𝗺𝗼𝘃𝗲𝗦𝘁𝗮𝗿𝘁𝗕𝗲𝗳𝗼𝗿𝗲($e);
    ok -p $a, <<END;
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b/>
   <c/>
   <d>
    <e/>
   </d>
  </a>
  END
   }

moveEndLast($@)

Move the end of a $node to contain all of its following siblings as children. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose end should be moved
  2  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
   </b>
   <d/>
   <e/>
  </a>
  END

    my ($c, $b, $d, $e) = $a->byList;

    $b->𝗺𝗼𝘃𝗲𝗘𝗻𝗱𝗟𝗮𝘀𝘁;
    ok -p $a, <<END;
  <a>
    <b>
      <c/>
      <d/>
      <e/>
    </b>
  </a>
  END
   }

moveEndAfter($$@)

Move the end of a $node to just after the specified $target node assuming that the $target node is either a subsequent sibling or a child of $node. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose end should be moved
  2  $to        Target node
  3  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
   </b>
   <d/>
   <e/>
  </a>
  END

    my ($c,  $b, $d, $e) = $a->byList;

    $b->𝗺𝗼𝘃𝗲𝗘𝗻𝗱𝗔𝗳𝘁𝗲𝗿($d);
    ok -p $a, <<END;
  <a>
    <b>
      <c/>
      <d/>
    </b>
    <e/>
  </a>
  END

    $b->𝗺𝗼𝘃𝗲𝗘𝗻𝗱𝗔𝗳𝘁𝗲𝗿($c);
    ok -p $a, <<END;
  <a>
    <b>
      <c/>
    </b>
    <d/>
    <e/>
  </a>
  END
   }

moveEndBefore($$@)

Move the end of a $node to just before the specified $target node assuming that the $target node is either a subsequent sibling or a child of $node. Returns $node if the move was made successfully, else confess that the specified move is impossible.

     Parameter  Description
  1  $node      Node whose end should be moved
  2  $to        Target node
  3  @context   Optional context of node.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
   <b>
    <c/>
   </b>
   <d/>
   <e/>
  </a>
  END

    my ($c,  $b, $d, $e) = $a->byList;

    $b->𝗺𝗼𝘃𝗲𝗘𝗻𝗱𝗕𝗲𝗳𝗼𝗿𝗲($e);
    ok -p $a, <<END;
  <a>
    <b>
      <c/>
      <d/>
    </b>
    <e/>
  </a>
  END

    $b->𝗺𝗼𝘃𝗲𝗘𝗻𝗱𝗕𝗲𝗳𝗼𝗿𝗲($d);
    ok -p $a, <<END;
  <a>
    <b>
      <c/>
    </b>
    <d/>
    <e/>
  </a>
  END
   }

Add selectively

Add new nodes unless they already exist.

addFirst($$%)

Add a new node first below the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

   {my $a = Data::Edit::Xml::newTree(q(a));

    $a->𝗮𝗱𝗱𝗙𝗶𝗿𝘀𝘁(qw(b id b)) for 1..2;

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
  </a>
  END

addNext($$%)

Add a new node next to the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
    <e id="e"/>
  </a>
  END

    $a->addFirst(qw(b id B))->𝗮𝗱𝗱𝗡𝗲𝘅𝘁(qw(c id c));

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
    <c id="c"/>
    <e id="e"/>
  </a>
  END

addPrev($$%)

Add a new node before the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
    <c id="c"/>
    <e id="e"/>
  </a>
  END

    $a->addLast(qw(e id E))->𝗮𝗱𝗱𝗣𝗿𝗲𝘃(qw(d id d));

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
    <c id="c"/>
    <d id="d"/>
    <e id="e"/>
  </a>
  END

addLast($$%)

Add a new node last below the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
  </a>
  END

    $a->𝗮𝗱𝗱𝗟𝗮𝘀𝘁(qw(e id e)) for 1..2;

    ok -p $a eq <<END;
  <a>
    <b id="b"/>
    <e id="e"/>
  </a>
  END

addWrapWith($$%)

Wrap the specified $node with the specified tag if the node is not already wrapped with such a tag and return the new node unless a node with that tag already exists in which case return the existing $node.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

   {my $a = Data::Edit::Xml::new(q(<a><b/></a>));

    my $b = $a->first;

    $b->𝗮𝗱𝗱𝗪𝗿𝗮𝗽𝗪𝗶𝘁𝗵(qw(c id c)) for 1..2;

    ok -p $a eq <<END;
  <a>
    <c id="c">
      <b/>
    </c>
  </a>
  END

addSingleChild($$%)

Wrap the content of a specified $node in a new node with the specified $tag and optional %attribute unless the content is already wrapped in a single child with the specified $tag.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag of new node
  3  %attributes  Attributes for the new node.

Example:

    ok -p $a eq <<END;
  <a>
    <c id="c">
      <b/>
    </c>
  </a>
  END

    $a->𝗮𝗱𝗱𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱(q(d)) for 1..2;

    ok -p $a eq <<END;
  <a>
    <d>
      <c id="c">
        <b/>
      </c>
    </d>
  </a>
  END

Add text selectively

Add new text unless it already exists.

addFirstAsText($$)

Add a new text node first below the specified $node and return the new node unless a text node already exists there and starts with the same text in which case return the existing $node.

     Parameter  Description
  1  $node      Node
  2  $text      Text

Example:

   {my $a = Data::Edit::Xml::newTree(q(a));

    $a->𝗮𝗱𝗱𝗙𝗶𝗿𝘀𝘁𝗔𝘀𝗧𝗲𝘅𝘁(q(aaaa)) for 1..2;

    ok -s $a eq q(<a>aaaa</a>);

addNextAsText($$)

Add a new text node after the specified $node and return the new node unless a text node already exists there and starts with the same text in which case return the existing $node.

     Parameter  Description
  1  $node      Node
  2  $text      Text

Example:

   {my $a = Data::Edit::Xml::new(q(<a><b/></a>));

    $a->go(q(b))->𝗮𝗱𝗱𝗡𝗲𝘅𝘁𝗔𝘀𝗧𝗲𝘅𝘁(q(bbbb)) for 1..2;

    ok -p $a eq <<END;
  <a>
    <b/>
  bbbb
  </a>
  END

addPrevAsText($$)

Add a new text node before the specified $node and return the new node unless a text node already exists there and ends with the same text in which case return the existing $node.

     Parameter  Description
  1  $node      Node
  2  $text      Text

Example:

    ok -p $a eq <<END;
  <a>
    <b/>
  bbbb
  </a>
  END

    $a->go(q(b))->𝗮𝗱𝗱𝗣𝗿𝗲𝘃𝗔𝘀𝗧𝗲𝘅𝘁(q(aaaa)) for 1..2;

    ok -p $a eq <<END;
  <a>aaaa
    <b/>
  bbbb
  </a>
  END

addLastAsText($$)

Add a new text node last below the specified $node and return the new node unless a text node already exists there and ends with the same text in which case return the existing $node.

     Parameter  Description
  1  $node      Node
  2  $text      Text

Example:

    ok -s $a eq q(<a>aaaa</a>);

    $a->𝗮𝗱𝗱𝗟𝗮𝘀𝘁𝗔𝘀𝗧𝗲𝘅𝘁(q(dddd)) for 1..2;

    ok -s $a eq q(<a>aaaadddd</a>);

Fusion

Join consecutive nodes

concatenate($$@)

Concatenate two successive nodes and return the target node.

     Parameter  Description
  1  $target    Target node to replace
  2  $source    Node to concatenate
  3  @context   Optional context of $target

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $s = <<END;
  <a>
    <b>
      <A/>
      <B/>
    </b>
    <c>
      <C/>
      <D/>
    </c>
  </a>
  END

    my $a = Data::Edit::Xml::new($s);

    $a->go(q(b))->𝗰𝗼𝗻𝗰𝗮𝘁𝗲𝗻𝗮𝘁𝗲($a->go(q(c)));

    my $t = <<END;
  <a>
    <b>
      <A/>
      <B/>
      <C/>
      <D/>
    </b>
  </a>
  END

    ok $t eq -p $a;

concatenateSiblings($@)

Concatenate preceding and following nodes as long as they have the same tag as the specified $node and return the specified $node.

     Parameter  Description
  1  $node      Concatenate around this node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="1"/>
    </b>
    <b>
      <c id="2"/>
    </b>
    <b>
      <c id="3"/>
    </b>
    <b>
      <c id="4"/>
    </b>
  </a>
  END

    $a->go(qw(b 3))->𝗰𝗼𝗻𝗰𝗮𝘁𝗲𝗻𝗮𝘁𝗲𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝘀;

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="1"/>
      <c id="2"/>
      <c id="3"/>
      <c id="4"/>
    </b>
  </a>
  END

mergeDuplicateChildWithParent($@)

Merge a parent node with its only child if their tags are the same and their attributes do not collide other than possibly the id in which case the parent id is used. Any labels on the child are transferred to the parent. The child node is then unwrapped and the parent node is returned.

     Parameter  Description
  1  $parent    Parent this node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b   id="b" b="bb">
      <b id="c" c="cc"/>
    </b>
  </a>
  END

    my ($c, $b) = $a->byList;

    is_deeply [$b->id, $c->id], [qw(b c)];

    ok $c == $b->hasSingleChild;

    $b->𝗺𝗲𝗿𝗴𝗲𝗗𝘂𝗽𝗹𝗶𝗰𝗮𝘁𝗲𝗖𝗵𝗶𝗹𝗱𝗪𝗶𝘁𝗵𝗣𝗮𝗿𝗲𝗻𝘁;

    ok -p $a eq <<END;
  <a>
    <b b="bb" c="cc" id="b"/>
  </a>
  END

    ok $b == $a->hasSingleChild;

Put as text

Add text to the parse tree.

putFirstAsText($$@)

Add a new text node first under a parent and return the new text node.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be added which might contain unparsed Xml as well as text
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
  </a>
  END

    $x->go(qw(b c))->𝗽𝘂𝘁𝗙𝗶𝗿𝘀𝘁𝗔𝘀𝗧𝗲𝘅𝘁("<d id=\"dd\">DDDD</d>");

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d></c>
    </b>
  </a>
  END

putLastAsText($$@)

Add a new text node last under a parent and return the new text node.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be added which might contain unparsed Xml as well as text
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d></c>
    </b>
  </a>
  END

    $x->go(qw(b c))->𝗽𝘂𝘁𝗟𝗮𝘀𝘁𝗔𝘀𝗧𝗲𝘅𝘁("<e id=\"ee\">EEEE</e>");

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d><e id="ee">EEEE</e></c>
    </b>
  </a>
  END

putNextAsText($$@)

Add a new text node following the specified $node and return the new text node.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be added which might contain unparsed Xml as well as text
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d><e id="ee">EEEE</e></c>
    </b>
  </a>
  END

    $x->go(qw(b c))->𝗽𝘂𝘁𝗡𝗲𝘅𝘁𝗔𝘀𝗧𝗲𝘅𝘁("<n id=\"nn\">NNNN</n>");

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d><e id="ee">EEEE</e></c>
  <n id="nn">NNNN</n>
    </b>
  </a>
  END

putPrevAsText($$@)

Add a new text node following the specified $node and return the new text node

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be added which might contain unparsed Xml as well as text
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"><d id="dd">DDDD</d><e id="ee">EEEE</e></c>
  <n id="nn">NNNN</n>
    </b>
  </a>
  END

    $x->go(qw(b c))->𝗽𝘂𝘁𝗣𝗿𝗲𝘃𝗔𝘀𝗧𝗲𝘅𝘁("<p id=\"pp\">PPPP</p>");

    ok -p $x eq <<END;
  <a id="aa">
    <b id="bb"><p id="pp">PPPP</p>
      <c id="cc"><d id="dd">DDDD</d><e id="ee">EEEE</e></c>
  <n id="nn">NNNN</n>
    </b>
  </a>
  END

Put as tree

Add parsed text to the parse tree.

putFirstAsTree($$@)

Put parsed text first under the specified $node parent and return a reference to the parsed tree. Confess if the text cannot be parsed successfully.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be parsed and added
  3  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a/>));

    ok -p $a eq <<END;
  <a/>
  END

    my $b = $a->𝗽𝘂𝘁𝗙𝗶𝗿𝘀𝘁𝗔𝘀𝗧𝗿𝗲𝗲(q(<b/>));
    ok -p $a eq <<END;
  <a>
    <b/>
  </a>
  END

    $b->putNextAsTree(q(<c/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
  </a>
  END

    my $e = $a->putLastAsTree(q(<e/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <e/>
  </a>
  END

    $e->putPrevAsTree(q(<d/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
  </a>
  END
   }

putLastAsTree($$@)

Put parsed text last under the specified $node parent and return a reference to the parsed tree. Confess if the text cannot be parsed successfully.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be parsed and added
  3  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a/>));

    ok -p $a eq <<END;
  <a/>
  END

    my $b = $a->putFirstAsTree(q(<b/>));
    ok -p $a eq <<END;
  <a>
    <b/>
  </a>
  END

    $b->putNextAsTree(q(<c/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
  </a>
  END

    my $e = $a->𝗽𝘂𝘁𝗟𝗮𝘀𝘁𝗔𝘀𝗧𝗿𝗲𝗲(q(<e/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <e/>
  </a>
  END

    $e->putPrevAsTree(q(<d/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
  </a>
  END
   }

putNextAsTree($$@)

Put parsed text after the specified $node parent and return a reference to the parsed tree. Confess if the text cannot be parsed successfully.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be parsed and added
  3  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a/>));

    ok -p $a eq <<END;
  <a/>
  END

    my $b = $a->putFirstAsTree(q(<b/>));
    ok -p $a eq <<END;
  <a>
    <b/>
  </a>
  END

    $b->𝗽𝘂𝘁𝗡𝗲𝘅𝘁𝗔𝘀𝗧𝗿𝗲𝗲(q(<c/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
  </a>
  END

    my $e = $a->putLastAsTree(q(<e/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <e/>
  </a>
  END

    $e->putPrevAsTree(q(<d/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
  </a>
  END
   }

putPrevAsTree($$@)

Put parsed text before the specified $parent parent and return a reference to the parsed tree. Confess if the text cannot be parsed successfully.

     Parameter  Description
  1  $node      The parent node
  2  $text      The string to be parsed and added
  3  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a/>));

    ok -p $a eq <<END;
  <a/>
  END

    my $b = $a->putFirstAsTree(q(<b/>));
    ok -p $a eq <<END;
  <a>
    <b/>
  </a>
  END

    $b->putNextAsTree(q(<c/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
  </a>
  END

    my $e = $a->putLastAsTree(q(<e/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <e/>
  </a>
  END

    $e->𝗽𝘂𝘁𝗣𝗿𝗲𝘃𝗔𝘀𝗧𝗿𝗲𝗲(q(<d/>));
    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
    <e/>
  </a>
  END
   }

Break in and out

Break nodes out of nodes or push them back

breakIn($@)

Concatenate the nodes following and preceding the start node, unwrapping nodes whose tag matches the start node and return the start node. To concatenate only the preceding nodes, use breakInBackwards, to concatenate only the following nodes, use breakInForwards.

     Parameter  Description
  1  $start     The start node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a>
    <d/>
    <b>
      <c/>
      <c/>
    </b>
    <e/>
    <b>
      <c/>
      <c/>
    </b>
    <d/>
  </a>
  END

      $a->go(qw(b 1))->𝗯𝗿𝗲𝗮𝗸𝗜𝗻;

      ok -p $a eq <<END;
  <a>
    <b>
      <d/>
      <c/>
      <c/>
      <e/>
      <c/>
      <c/>
      <d/>
    </b>
  </a>
  END

breakInForwards($@)

Concatenate the nodes following the start node, unwrapping nodes whose tag matches the start node and return the start node in the manner of breakIn.

     Parameter  Description
  1  $start     The start node
  2  @context   Optional context..

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a>
    <d/>
    <b>
      <c/>
      <c/>
    </b>
    <e/>
    <b>
      <c/>
      <c/>
    </b>
    <d/>
  </a>
  END

      $a->go(q(b))->𝗯𝗿𝗲𝗮𝗸𝗜𝗻𝗙𝗼𝗿𝘄𝗮𝗿𝗱𝘀;

      ok -p $a eq <<END;
  <a>
    <d/>
    <b>
      <c/>
      <c/>
      <e/>
      <c/>
      <c/>
      <d/>
    </b>
  </a>
  END

breakInBackwards($@)

Concatenate the nodes preceding the start node, unwrapping nodes whose tag matches the start node and return the start node in the manner of breakIn.

     Parameter  Description
  1  $start     The start node
  2  @context   Optional context..

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $a eq <<END;
  <a>
    <d/>
    <b>
      <c/>
      <c/>
    </b>
    <e/>
    <b>
      <c/>
      <c/>
    </b>
    <d/>
  </a>
  END

      $a->go(qw(b 1))->𝗯𝗿𝗲𝗮𝗸𝗜𝗻𝗕𝗮𝗰𝗸𝘄𝗮𝗿𝗱𝘀;

      ok -p $a eq <<END;
  <a>
    <b>
      <d/>
      <c/>
      <c/>
      <e/>
      <c/>
      <c/>
    </b>
    <d/>
  </a>
  END

breakOut($@)

Lift child nodes with the specified tags under the specified parent node splitting the parent node into clones and return the cut out original node.

     Parameter  Description
  1  $parent    The parent node
  2  @tags      The tags of the modes to be broken out.

Example:

   {my $A = Data::Edit::Xml::new("<a><b><d/><c/><c/><e/><c/><c/><d/></b></a>");

      $a->go(q(b))->𝗯𝗿𝗲𝗮𝗸𝗢𝘂𝘁($a, qw(d e));

      ok -p $a eq <<END;
  <a>
    <d/>
    <b>
      <c/>
      <c/>
    </b>
    <e/>
    <b>
      <c/>
      <c/>
    </b>
    <d/>
  </a>
  END

Replace

Replace nodes in the parse tree with nodes or text

replaceWith($$@)

Replace a node (and all its content) with a new node (and all its content) and return the new node. If the node to be replaced is the root of the parse tree then no action is taken other then returning the new node.

     Parameter  Description
  1  $old       Old node
  2  $new       New node
  3  @context   Optional context..

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

     {my $x = Data::Edit::Xml::new(qq(<a><b><c id="cc"/></b></a>));

      $x->go(qw(b c))->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗪𝗶𝘁𝗵($x->newTag(qw(d id dd)));

      ok -s $x eq '<a><b><d id="dd"/></b></a>';

replaceWithText($$@)

Replace a node (and all its content) with a new text node and return the new node.

     Parameter  Description
  1  $old       Old node
  2  $text      Text of new node
  3  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

     {my $x = Data::Edit::Xml::new(qq(<a><b><c id="cc"/></b></a>));

      $x->go(qw(b c))->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗪𝗶𝘁𝗵𝗧𝗲𝘅𝘁(qq(BBBB));

      ok -s $x eq '<a><b>BBBB</b></a>';

replaceWithBlank($@)

Replace a node (and all its content) with a new blank text node and return the new node.

     Parameter  Description
  1  $old       Old node
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

     {my $x = Data::Edit::Xml::new(qq(<a><b><c id="cc"/></b></a>));

      $x->go(qw(b c))->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗪𝗶𝘁𝗵𝗕𝗹𝗮𝗻𝗸;

      ok -s $x eq '<a><b> </b></a>';

replaceContentWithMovedContent($@)

Replace the content of a specified target node with the contents of the specified source nodes removing the content from each source node and return the target node.

     Parameter  Description
  1  $node      Target node
  2  @nodes     Source nodes

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
       <b1/>
       <b2/>
    </b>
    <c>
       <c1/>
       <c2/>
    </c>
    <d>
       <d1/>
       <d2/>
    </d>
  </a>
  END

    my ($b, $c, $d) = $a->contents;

    $d->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗪𝗶𝘁𝗵𝗠𝗼𝘃𝗲𝗱𝗖𝗼𝗻𝘁𝗲𝗻𝘁($c, $b);

    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d>
      <c1/>
      <c2/>
      <b1/>
      <b2/>
    </d>
  </a>
  END

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <d>
       <b>
         <b1/>
         <b2/>
      </b>
      <c>
         <c1/>
         <c2/>
      </c>
    </d>
  </a>
  END

    my ($d)     = $a->contents;

    my ($b, $c) = $d->contents;

    $d->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗪𝗶𝘁𝗵𝗠𝗼𝘃𝗲𝗱𝗖𝗼𝗻𝘁𝗲𝗻𝘁($c, $b);

    ok -p $a eq <<END;
  <a>
    <d>
      <c1/>
      <c2/>
      <b1/>
      <b2/>
    </d>
  </a>
  END

replaceContentWith($@)

Replace the content of a node with the specified nodes and return the replaced content

     Parameter  Description
  1  $node      Node whose content is to be replaced
  2  @content   New content

Example:

     {my $x = Data::Edit::Xml::new(qq(<a><b/><c/></a>));

      $x->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗪𝗶𝘁𝗵(map {$x->newTag($_)} qw(B C));

      ok -s $x eq '<a><B/><C/></a>';

replaceContentWithText($@)

Replace the content of a node with the specified texts and return the replaced content

     Parameter  Description
  1  $node      Node whose content is to be replaced
  2  @text      Texts to form new content

Example:

     {my $x = Data::Edit::Xml::new(qq(<a><b/><c/></a>));

      $x->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗪𝗶𝘁𝗵𝗧𝗲𝘅𝘁(qw(b c));

      ok -s $x eq '<a>bc</a>';

Swap

Swap nodes both singly and in blocks

invert($@)

Swap a parent and child node where the child is the only child of the parent and return the parent.

     Parameter  Description
  1  $parent    Parent
  2  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b id="b">
      <c id="c">
        <d/>
        <e/>
      </c>
    </b>
  </a>
  END

    $a->first->𝗶𝗻𝘃𝗲𝗿𝘁;

    ok -p $a eq <<END;
  <a>
    <c id="c">
      <b id="b">
        <d/>
        <e/>
      </b>
    </c>
  </a>
  END

    $a->first->𝗶𝗻𝘃𝗲𝗿𝘁;

    ok -p $a eq <<END;
  <a>
    <b id="b">
      <c id="c">
        <d/>
        <e/>
      </c>
    </b>
  </a>
  END

invertFirst($@)

Swap a parent and child node where the child is the first child of the parent by placing the parent last in the child. Return the parent.

     Parameter  Description
  1  $parent    Parent
  2  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
        <e/>
      </c>
      <f/>
      <g/>
    </b>
  </a>
  END

    ok -p $a eq <<END;
  <a>
    <c>
      <d/>
      <e/>
      <b>
        <f/>
        <g/>
      </b>
    </c>
  </a>
  END

invertLast($@)

Swap a parent and child node where the child is the last child of the parent by placing the parent first in the child. Return the parent.

     Parameter  Description
  1  $parent    Parent
  2  @context   Context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
        <e/>
      </c>
      <f/>
      <g/>
    </b>
  </a>
  END

    ok -p $a eq <<END;
  <a>
    <c>
      <d/>
      <e/>
      <b>
        <f/>
        <g/>
      </b>
    </c>
  </a>
  END

    ok -p $a eq <<END;
  <a>
    <b>
      <c>
        <d/>
        <e/>
      </c>
      <f/>
      <g/>
    </b>
  </a>
  END

swap($$@)

Swap two nodes optionally checking that the first node is in the specified context and return the first node.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok <<END eq -p $x;
  <x>
    <a a="1" b="2"/>
    <b/>
    <c a="1" b="3" c="4"/>
  </x>
  END

    $a->𝘀𝘄𝗮𝗽($c);

    ok <<END eq -p $x;
  <x>
    <c a="1" b="3" c="4"/>
    <b/>
    <a a="1" b="2"/>
  </x>
  END

swapTags($$@)

Swap the tags of two nodes optionally checking that the first node is in the specified context and return ($first, $second) nodes.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
    </b>
  </a>
  END

    $a->𝘀𝘄𝗮𝗽𝗧𝗮𝗴𝘀($a->first);
    ok -p $a eq <<END;
  <b>
    <a>
      <c/>
    </a>
  </b>
  END

    my ($C, $A) = $a->downWhileFirst->swapTagWithParent;
    ok -t $A eq q(a);
    ok -t $C eq q(c);
    ok -p $a eq <<END;
  <b>
    <c>
      <a/>
    </c>
  </b>
  END
   }

swapTagWithParent($@)

Swap the tags of the specified $node and its parent optionally checking that the $node is in the specified context and return (parent of $node, $node) or () if there is no such parent node.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
    </b>
  </a>
  END

    $a->swapTags($a->first);
    ok -p $a eq <<END;
  <b>
    <a>
      <c/>
    </a>
  </b>
  END

    my ($C, $A) = $a->downWhileFirst->𝘀𝘄𝗮𝗽𝗧𝗮𝗴𝗪𝗶𝘁𝗵𝗣𝗮𝗿𝗲𝗻𝘁;
    ok -t $A eq q(a);
    ok -t $C eq q(c);
    ok -p $a eq <<END;
  <b>
    <c>
      <a/>
    </c>
  </b>
  END
   }

Wrap and unwrap

Wrap and unwrap nodes to alter the depth of the parse tree

Wrap

Wrap nodes to deepen the parse tree

wrapWith($$@)

Wrap the specified $node in a new node created from the specified $tag and %attributes forcing the specified $node down - deepening the parse tree - return the new wrapping node. See addWrapWith to perform this operation conditionally.

     Parameter    Description
  1  $node        Node
  2  $tag         Tag for the new node or tag
  3  %attributes  Attributes for the new node or tag.

Example:

    ok -p $x eq <<END;
  <a>
    <b>
      <c id="11"/>
    </b>
  </a>
  END

    $x->go(qw(b c))->𝘄𝗿𝗮𝗽𝗪𝗶𝘁𝗵(qw(C id 1));

    ok -p $x eq <<END;
  <a>
    <b>
      <C id="1">
        <c id="11"/>
      </C>
    </b>
  </a>
  END

wrapUp($@)

Wrap the specified $node in a sequence of new nodes created from the specified @tags forcing the original node down - deepening the parse tree - return the array of wrapping nodes.

     Parameter  Description
  1  $node      Node to wrap
  2  @tags      Tags to wrap the node with - with the uppermost tag rightmost.

Example:

   {my $c = Data::Edit::Xml::newTree("c", id=>33);

    my ($b, $a) = $c->𝘄𝗿𝗮𝗽𝗨𝗽(qw(b a));

    ok -p $a eq <<'END';
  <a>
    <b>
      <c id="33"/>
    </b>
  </a>
  END

wrapDown($@)

Wrap the content of the specified $node in a sequence of new nodes forcing the original node up - deepening the parse tree - return the array of wrapping nodes.

     Parameter  Description
  1  $node      Node to wrap
  2  @tags      Tags to wrap the node with - with the uppermost tag rightmost.

Example:

   {my $a = Data::Edit::Xml::newTree("a", id=>33);

    my ($b, $c) = $a->𝘄𝗿𝗮𝗽𝗗𝗼𝘄𝗻(qw(b c));

    ok -p $a eq <<END;
  <a id="33">
    <b>
      <c/>
    </b>
  </a>
  END

wrapContentWith($$@)

Wrap the content of the specified $node in a new node created from the specified <@tag> and %attributes: the specified $node then contains just the new node which, in turn, contains all the content of the specified $node.

Returns the new wrapped node.

     Parameter    Description
  1  $old         Node
  2  $tag         Tag for new node
  3  %attributes  Attributes for new node.

Example:

    ok -p $x eq <<END;
  <a>
    <b>
      <c/>
      <c/>
      <c/>
    </b>
  </a>
  END

    $x->go(q(b))->𝘄𝗿𝗮𝗽𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝗪𝗶𝘁𝗵(qw(D id DD));

    ok -p $x eq <<END;
  <a>
    <b>
      <D id="DD">
        <c/>
        <c/>
        <c/>
      </D>
    </b>
  </a>
  END

    ok -p $a eq <<END;
  <a>
    <b id="1"/>
    <c id="2"/>
    <d id="3"/>
    <c id="4"/>
    <d id="5"/>
    <e id="6"/>
    <b id="7"/>
    <c id="8"/>
    <d id="9"/>
    <f id="10"/>
  </a>
  END

wrapSiblingsBefore($$@)

If there are any siblings before the specified $node, wrap them with a new node created from the specified <@tag> and %attributes.

Returns the specified $node.

     Parameter    Description
  1  $node        Node to wrap before
  2  $tag         Tag for new node
  3  %attributes  Attributes for new node.

Example:

   {my $a = Data::Edit::Xml::new(q(<a><b/><c/><d/></a>));

    my ($b, $c, $d) = $a->byList;

    $c->𝘄𝗿𝗮𝗽𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝘀𝗕𝗲𝗳𝗼𝗿𝗲(q(X));

    ok -p $a eq <<END;
  <a>
    <X>
      <b/>
    </X>
    <c/>
    <d/>
  </a>
  END

wrapFromFirst($$@)

Wrap this $node and any preceding siblings with a new node created from the specified <@tag> and %attributes and return the wrapping node.

     Parameter    Description
  1  $node        Node to wrap before
  2  $tag         Tag for new node
  3  %attributes  Attributes for new node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b/><c/><d/></a>));

    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
  </a>
  END

    $a->go_c->wrapFromFirst_B;
    ok -p $a eq <<END;
  <a>
    <B>
      <b/>
      <c/>
    </B>
    <d/>
  </a>
  END
   }

wrapSiblingsBetween($$$@)

If there are any siblings between the specified $nodes, wrap them with a new node created from the specified <@tag> and %attributes. Return the wrapping node else undef if there are no nodes to wrap.

     Parameter    Description
  1  $first       First sibling
  2  $last        Last sibling
  3  $tag         Tag for new node
  4  %attributes  Attributes for new node.

Example:

   {my $a = Data::Edit::Xml::new(q(<a><b/><c/><d/></a>));

    my ($b, $c, $d) = $a->byList;

    $b->𝘄𝗿𝗮𝗽𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝘀𝗕𝗲𝘁𝘄𝗲𝗲𝗻($d, q(Y));

    ok -p $a eq <<END;
  <a>
    <b/>
    <Y>
      <c/>
    </Y>
    <d/>
  </a>
  END

wrapSiblingsAfter($$@)

If there are any siblings after the specified $node, wrap them with a new node created from the specified <@tag> and %attributes.

Return the specified $node.

     Parameter    Description
  1  $node        Node to wrap before
  2  $tag         Tag for new node
  3  %attributes  Attributes for new node.

Example:

   {my $a = Data::Edit::Xml::new(q(<a><b/><c/><d/></a>));

    my ($b, $c, $d) = $a->byList;

    $c->𝘄𝗿𝗮𝗽𝗦𝗶𝗯𝗹𝗶𝗻𝗴𝘀𝗔𝗳𝘁𝗲𝗿(q(Y));

    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <Y>
      <d/>
    </Y>
  </a>
  END

wrapToLast($$@)

Wrap this $node and any following siblings with a new node created from the specified <@tag> and %attributes and return the wrapping node.

     Parameter    Description
  1  $node        Node to wrap before
  2  $tag         Tag for new node
  3  %attributes  Attributes for new node.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a><b/><c/><d/></a>));

    ok -p $a eq <<END;
  <a>
    <b/>
    <c/>
    <d/>
  </a>
  END

    $a->go_c->wrapToLast_D;
    ok -p $a eq <<END;
  <a>
    <b/>
    <D>
      <c/>
      <d/>
    </D>
  </a>
  END
   }

wrapTo($$$@)

Wrap all the nodes from the $start node to the $end node inclusive with a new node created from the specified <@tag> and %attributes and return the new node.

Return undef if the $start and $end nodes are not siblings - they must have the same parent for this method to work.

     Parameter    Description
  1  $start       Start node
  2  $end         End node
  3  $tag         Tag for the wrapping node
  4  %attributes  Attributes for the wrapping node

Example:

   {my $x = Data::Edit::Xml::new(my $s = <<END);
  <aa>
    <a>
      <b/>
        <c id="1"/><c id="2"/><c id="3"/><c id="4"/>
      <d/>
    </a>
  </aa>
  END

    $x->go(qw(a c))->𝘄𝗿𝗮𝗽𝗧𝗼($x->go(qw(a c -1)), qq(C), id=>1234);

    ok -p $x eq <<END;
  <aa>
    <a>
      <b/>
      <C id="1234">
        <c id="1"/>
        <c id="2"/>
        <c id="3"/>
        <c id="4"/>
      </C>
      <d/>
    </a>
  </aa>
  END

    my $C = $x->go(qw(a C));

    $C->𝘄𝗿𝗮𝗽𝗧𝗼($C, qq(D));

    ok -p $x eq <<END;
  <aa>
    <a>
      <b/>
      <D>
        <C id="1234">
          <c id="1"/>
          <c id="2"/>
          <c id="3"/>
          <c id="4"/>
        </C>
      </D>
      <d/>
    </a>
  </aa>
  END

    ok -p $a eq <<END;
  <a>
    <b>
      <D id="DD">
        <c id="0"/>
        <c id="1"/>
      </D>
      <E id="EE">
        <c id="2"/>
      </E>
      <F id="FF">
        <c id="3"/>
      </F>
    </b>
  </a>
  END

wrapFrom($$$%)

Wrap all the nodes from the $start node to the $end node with a new node created from the specified <@tag> and %attributes and return the new node. Return undef if the $start and $end nodes are not siblings - they must have the same parent for this method to work.

     Parameter    Description
  1  $end         End node
  2  $start       Start node
  3  $tag         Tag for the wrapping node
  4  %attributes  Attributes for the wrapping node

Example:

   {my $a = Data::Edit::Xml::new(my $s = <<END);
  <a>
    <b>
      <c id="0"/><c id="1"/><c id="2"/><c id="3"/>
    </b>
  </a>
  END

    my $b = $a->first;

    my @c = $b->contents;

    $c[1]->𝘄𝗿𝗮𝗽𝗙𝗿𝗼𝗺($c[0], qw(D id DD));

    ok -p $a eq <<END;
  <a>
    <b>
      <D id="DD">
        <c id="0"/>
        <c id="1"/>
      </D>
      <c id="2"/>
      <c id="3"/>
    </b>
  </a>
  END

Unwrap

Unwrap nodes to reduce the depth of the parse tree

unwrap($@)

Unwrap the specified $node by inserting its content into its parent at the point containing the specified $node and return the parent node. Returns undef if an attempt is made to unwrap a text node. Confesses if an attempt is made to unwrap the root node.

     Parameter  Description
  1  $node      Node to unwrap
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -s $x eq "<a>A<b> c </b>B</a>";

    $b->𝘂𝗻𝘄𝗿𝗮𝗽;

    ok -s $x eq "<a>A c B</a>";

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaa</a>));

    my  $t = $a->first;
    ok !$t->𝘂𝗻𝘄𝗿𝗮𝗽;
   }

unwrapParentsWithSingleChild($)

Unwrap any immediate ancestors of the specified $node which have only a single child and return the specified $node regardless.

     Parameter  Description
  1  $o         Node

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <e/>
  </a>
  END

    $a->go(qw(b c d))->𝘂𝗻𝘄𝗿𝗮𝗽𝗣𝗮𝗿𝗲𝗻𝘁𝘀𝗪𝗶𝘁𝗵𝗦𝗶𝗻𝗴𝗹𝗲𝗖𝗵𝗶𝗹𝗱;

    ok -p $a eq <<END;
  <a>
    <d/>
    <e/>
  </a>
  END

unwrapContentsKeepingText($@)

Unwrap all the non text nodes below the specified $node adding a leading and a trailing space to prevent unwrapped content from being elided and return the specified $node else undef if not in the optional context.

     Parameter  Description
  1  $node      Node to unwrap
  2  @context   Optional context.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

      ok -p $x eq <<END;
  <a>
    <b>
      <c>
        <d>DD</d>
  EE
        <f>FF</f>
      </c>
    </b>
  </a>
  END

      $x->go(qw(b))->𝘂𝗻𝘄𝗿𝗮𝗽𝗖𝗼𝗻𝘁𝗲𝗻𝘁𝘀𝗞𝗲𝗲𝗽𝗶𝗻𝗴𝗧𝗲𝘅𝘁;

      ok -p $x eq <<END;
  <a>
    <b>  DD EE FF  </b>
  </a>
  END

wrapRuns($$@)

Wrap consecutive runs of children under the specified parent $node that are not already wrapped with $wrap. Returns an array of any wrapping nodes created. Returns () if the specified $node is not in the optional @context.

     Parameter  Description
  1  $node      Node to unwrap
  2  $wrap      Tag of wrapping node
  3  @context   Optional context.

Example:

    ok -p $a eq <<END;
  <a id="i1">
    <b id="i2"/>
    <c id="i3"/>
    <B id="i4">
      <c id="i5"/>
    </B>
    <c id="i6"/>
    <b id="i7"/>
  </a>
  END

    $a->𝘄𝗿𝗮𝗽𝗥𝘂𝗻𝘀(q(B));

    ok -p $a eq <<END;
  <a id="i1">
    <B>
      <b id="i2"/>
      <c id="i3"/>
    </B>
    <B id="i4">
      <c id="i5"/>
    </B>
    <B>
      <c id="i6"/>
      <b id="i7"/>
    </B>
  </a>
  END

Contents

The children of each node.

contents($@)

Return a list of all the nodes contained by the specified $node or an empty list if the node is empty or not in the optional context.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b id="b1"><c id="1"/></b>
    <d id="d1"><c id="2"/></d>
    <e id="e1"><c id="3"/></e>
    <b id="b2"><c id="4"/></b>
    <d id="d2"><c id="5"/></d>
    <e id="e2"><c id="6"/></e>
  </a>
  END

    is_deeply [map{-u $_} $x->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝘀], [qw(b1 d1 e1 b2 d2 e2)];

contentAfter($@)

Return a list of all the sibling nodes following the specified $node or an empty list if the specified $node is last or not in the optional context.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok 'f g' eq join ' ', map {$_->tag} $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗔𝗳𝘁𝗲𝗿;

contentBefore($@)

Return a list of all the sibling nodes preceding the specified $node (in the normal sibling order) or an empty list if the specified $node is last or not in the optional context.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok 'c d' eq join ' ', map {$_->tag} $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗕𝗲𝗳𝗼𝗿𝗲;

contentAsTags($@)

Return a string containing the tags of all the child nodes of the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context. Use over to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(q(b))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗔𝘀𝗧𝗮𝗴𝘀 eq 'c d e f g';

contentAsTags2($@)

Return a string containing the tags of all the child nodes of the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context. Use over2 to test the sequence of tags with a regular expression. Use over2 to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

    ok $x->go(q(b))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗔𝘀𝗧𝗮𝗴𝘀𝟮 eq q( c  d  e  f  g );

contentAfterAsTags($@)

Return a string containing the tags of all the sibling nodes following the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context. Use matchAfter to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok 'f g' eq join ' ', map {$_->tag} $x->go(qw(b e))->contentAfter;

    ok $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗔𝗳𝘁𝗲𝗿𝗔𝘀𝗧𝗮𝗴𝘀 eq 'f g';

contentAfterAsTags2($@)

Return a string containing the tags of all the sibling nodes following the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context. Use matchAfter2 to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗔𝗳𝘁𝗲𝗿𝗔𝘀𝗧𝗮𝗴𝘀𝟮 eq q( f  g );

contentBeforeAsTags($@)

Return a string containing the tags of all the sibling nodes preceding the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context. Use matchBefore to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok 'c d' eq join ' ', map {$_->tag} $x->go(qw(b e))->contentBefore;

    ok $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗕𝗲𝗳𝗼𝗿𝗲𝗔𝘀𝗧𝗮𝗴𝘀 eq 'c d';

contentBeforeAsTags2($@)

Return a string containing the tags of all the sibling nodes preceding the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context. Use matchBefore2 to test the sequence of tags with a regular expression.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context.

Use the @context parameter to test the context of the specified $node as understood by method at. If a context is supplied and $node is not in this context then this method returns an empty list () immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/><d/><e/><f/><g/>
    </b>
  </a>
  END

    ok $x->go(qw(b e))->𝗰𝗼𝗻𝘁𝗲𝗻𝘁𝗕𝗲𝗳𝗼𝗿𝗲𝗔𝘀𝗧𝗮𝗴𝘀𝟮 eq q( c  d );

position($)

Return the index of the specified $node in the content of the parent of the $node.

     Parameter  Description
  1  $node      Node.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok $a->go(qw(b 1 b))->id == 26;

    ok $a->go(qw(b 1 b))->𝗽𝗼𝘀𝗶𝘁𝗶𝗼𝗻 == 2;

index($)

Return the index of the specified $node in its parent index. Use position to find the position of a node under its parent.

     Parameter  Description
  1  $node      Node.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a         id="11">
    <b       id="12">
       <c    id="13"/>
       <d    id="14"/>
       <b    id="15">
          <c id="16"/>
          <d id="17"/>
          <e id="18"/>
          <f id="19"/>
          <g id="20"/>
       </b>
       <f    id="21"/>
       <g    id="22"/>
    </b>
    <b       id="23">
       <c    id="24"/>
       <d    id="25"/>
       <b    id="26">
          <c id="27"/>
          <d id="28"/>
          <e id="29"/>
          <f id="30"/>
          <g id="31"/>
       </b>
       <f    id="32"/>
       <g    id="33"/>
    </b>
  </a>
  END

    ok $a->go(qw(b 1))->id == 23;

    ok $a->go(qw(b 1))->𝗶𝗻𝗱𝗲𝘅 == 1;

present($@)

Return the count of the number of the specified tag types present immediately under a node or a hash {tag} = count for all the tags present under the node if no names are specified.

     Parameter  Description
  1  $node      Node
  2  @names     Possible tags immediately under the node.

Example:

    is_deeply {$a->first->𝗽𝗿𝗲𝘀𝗲𝗻𝘁}, {c=>2, d=>2, e=>1};

isText($@)

Return the specified $node if the specified $node is a text node, optionally in the specified context, else return undef.

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok $a->prettyStringCDATA eq <<END;
  <a>
      <b><CDATA> </CDATA></b>
  </a>
  END

    ok $b->first->𝗶𝘀𝗧𝗲𝘅𝘁;

    ok $b->first->𝗶𝘀𝗧𝗲𝘅𝘁(qw(b a));

isFirstText($@)

Return the specified $node if the specified $node is a text node, the first node under its parent and that the parent is optionally in the specified context, else return undef.

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context for parent

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a>aaa
      <b>bbb</b>
      ccc
      <d>ddd</d>
      eee
    </a>
  </x>
  END

    my $a = $x->first;

    my ($ta, $b, $tc, $d, $te) = $a->contents;

    ok $ta      ->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁(qw(a x));

    ok $b->first->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁(qw(b a x));

    ok $b->prev ->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁(qw(a x));

    ok $d->last ->𝗶𝘀𝗙𝗶𝗿𝘀𝘁𝗧𝗲𝘅𝘁(qw(d a x));

isLastText($@)

Return the specified $node if the specified $node is a text node, the last node under its parent and that the parent is optionally in the specified context, else return undef.

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context for parent

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
    <a>aaa
      <b>bbb</b>
      ccc
      <d>ddd</d>
      eee
    </a>
  </x>
  END

    ok $d->next ->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗲𝘅𝘁 (qw(a x));

    ok $d->last ->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗲𝘅𝘁 (qw(d a x));

    ok $te      ->𝗶𝘀𝗟𝗮𝘀𝘁𝗧𝗲𝘅𝘁 (qw(a x));

matchTree($@)

Return a list of nodes that match the specified tree of match expressions, else () if one or more match expressions fail to match nodes in the tree below the specified start node. A match expression consists of [parent node tag, [match expressions to be matched by children of parent]|tags of child nodes to match starting at the first node]. Match expressions for a single item do need to be surrounded with [] and can be merged into their predecessor. The outermost match expression should not be enclosed in [].

     Parameter  Description
  1  $node      Node to start matching from
  2  @match     Tree of match expressions.

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
    <e>
      <f>
        <g/>
      </f>
    </e>
  </a>
  END
    my ($c, $d, $b, $g, $f, $e) = $a->byList;

    is_deeply [$b, $c, $d], [$b->𝗺𝗮𝘁𝗰𝗵𝗧𝗿𝗲𝗲(qw(b c d))];
    is_deeply [$e, $f, $g], [$e->𝗺𝗮𝘁𝗰𝗵𝗧𝗿𝗲𝗲(qr(\Ae\Z), [qw(f g)])];
    is_deeply [$c],         [$c->𝗺𝗮𝘁𝗰𝗵𝗧𝗿𝗲𝗲(qw(c))];
    is_deeply [$a, $b, $c, $d, $e, $f, $g],
              [$a->𝗺𝗮𝘁𝗰𝗵𝗧𝗿𝗲𝗲({a=>1}, [qw(b c d)], [qw(e), [qw(f g)]])];
   }

matchesText($$@)

Returns an array of regular expression matches in the text of the specified $node if it is text node and it matches the specified regular expression and optionally has the specified context otherwise returns an empty array.

     Parameter  Description
  1  $node      Node to test
  2  $re        Regular expression
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>CDECD</c>
    </b>
  </a>
  END

    my $c = $x->go(qw(b c))->first;

    ok !$c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗧𝗲𝘅𝘁(qr(\AD));

    ok  $c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗧𝗲𝘅𝘁(qr(\AC), qw(c b a));

    ok !$c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗧𝗲𝘅𝘁(qr(\AD), qw(c b a));

    is_deeply [qw(E)], [$c->𝗺𝗮𝘁𝗰𝗵𝗲𝘀𝗧𝗲𝘅𝘁(qr(CD(.)CD))];

isBlankText($@)

Return the specified $node if the specified $node is a text node, optionally in the specified context, and contains nothing other than white space else return undef. See also: isAllBlankText

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok $a->prettyStringCDATA eq <<END;
  <a>
      <b><CDATA> </CDATA></b>
  </a>
  END

    ok $b->first->𝗶𝘀𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁;

isAllBlankText($@)

Return the specified $node if the specified $node, optionally in the specified context, does not contain anything or if it does contain something it is all white space else return undef. See also: bitsNodeTextBlank

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <z/>
      </c>
    </b>
    <d/>
  </a>
  END

    $a->by(sub{$_->replaceWithBlank(qw(z))});

    my ($b, $c, $d) = $a->firstBy(qw(b c d));

    ok  $c->𝗶𝘀𝗔𝗹𝗹𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁;

    ok  $c->𝗶𝘀𝗔𝗹𝗹𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁(qw(c b a));

    ok !$c->𝗶𝘀𝗔𝗹𝗹𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁(qw(c a));

isOnlyChildBlankText($@)

Return the specified $node if it is a blank text node and an only child else return undef.

     Parameter  Description
  1  $node      Node to test
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a>aaaa</a>));
    $a->first->text = q( );
    ok  $a->prettyStringCDATA eq qq(<a><CDATA> </CDATA></a>
);
    ok  $a->first->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁;
    ok !$a->𝗶𝘀𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱𝗕𝗹𝗮𝗻𝗸𝗧𝗲𝘅𝘁;
   }

  if (1)
   {my $a = Data::Edit::Xml::new(q(<a/>));
    my $b = $a->new(q(<b/>));
    ok -p $a eq qq(<a/>
);
    ok -p $b eq qq(<b/>
);
   }

bitsNodeTextBlank($)

Return a bit string that shows if there are any non text nodes, text nodes or blank text nodes under a node. An empty string is returned if there are no child nodes.

     Parameter  Description
  1  $node      Node to test.

Example:

    ok $x->prettyStringCDATA eq <<END;
  <a>
      <b>
          <C/>
      </b>
      <c>
          <D/>
  <CDATA>
       E
      </CDATA>
      </c>
      <d>
          <F/>
  <CDATA> </CDATA>
          <H/>
      </d>
      <e/>
  </a>
  END

    ok '100' eq -B $x;

    ok '100' eq -B $x->go(q(b));

    ok '110' eq -B $x->go(q(c));

    ok '111' eq -B $x->go(q(d));

    ok !-B $x->go(qw(e));

Number

Number the nodes of a parse tree so that they can be easily retrieved by number - either by a person reading the source xml or programmatically.

findByNumber($$)

Find the node with the specified number as made visible by prettyStringNumbered in the parse tree containing the specified $node and return the found node or undef if no such node exists.

     Parameter  Description
  1  $node      Node in the parse tree to search
  2  $number    Number of the node required.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/></b><d><e/></d></a>
  END

    $a->numberTree;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3"/>
    </b>
    <d id="4">
      <e id="5"/>
    </d>
  </a>
  END

    ok -t $a->findByNumber_4 eq q(d);
    ok    $a->findByNumber_3__up__number == 2;
   }

    $a->numberTree;

    ok $a->prettyStringNumbered eq <<END;
  <a id="1">
    <b id="2">
      <A id="3"/>
      <B id="4"/>
    </b>
    <c id="5">
      <C id="6"/>
      <D id="7"/>
    </c>
  </a>
  END

    ok q(D) eq -t $a->𝗳𝗶𝗻𝗱𝗕𝘆𝗡𝘂𝗺𝗯𝗲𝗿(7);

findByNumbers($@)

Find the nodes with the specified numbers as made visible by prettyStringNumbered in the parse tree containing the specified $node and return the found nodes in a list with undef for nodes that do not exist.

     Parameter  Description
  1  $node      Node in the parse tree to search
  2  @numbers   Numbers of the nodes required.

Example:

    $a->numberTree;

    ok $a->prettyStringNumbered eq <<END;
  <a id="1">
    <b id="2">
      <A id="3"/>
      <B id="4"/>
    </b>
    <c id="5">
      <C id="6"/>
      <D id="7"/>
    </c>
  </a>
  END

    is_deeply [map {-t $_} $a->𝗳𝗶𝗻𝗱𝗕𝘆𝗡𝘂𝗺𝗯𝗲𝗿𝘀(1..3)], [qw(a b A)];

numberTree($)

Number the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source. You can see the numbers by printing the tree with prettyStringNumbered. Nodes can be found using findByNumber. This method differs from forestNumberTrees in that avoids overwriting the id= attribute of each node by using a system attribute instead; this system attribute can then be made visible on the id attribute of each node by printing the parse tree with prettyStringNumbered.

     Parameter  Description
  1  $node      Node

Example:

    $a->𝗻𝘂𝗺𝗯𝗲𝗿𝗧𝗿𝗲𝗲;

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="42" match="mm"/>
    </b>
    <d id="4">
      <e id="5"/>
    </d>
  </a>
  END

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/></b><d><e/></d></a>
  END

    $a->𝗻𝘂𝗺𝗯𝗲𝗿𝗧𝗿𝗲𝗲;
    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3"/>
    </b>
    <d id="4">
      <e id="5"/>
    </d>
  </a>
  END

    ok -t $a->findByNumber_4 eq q(d);
    ok    $a->findByNumber_3__up__number == 2;
   }

indexIds($)

Return a map of the ids at and below the specified $node.

     Parameter  Description
  1  $node      Node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a id="A">
    <b id="B">
      <c id="C"/>
      <d id="D">
        <e id="E"/>
        <f id="F"/>
      </d>
    </b>
  </a>
  END

    my $i = $a->𝗶𝗻𝗱𝗲𝘅𝗜𝗱𝘀;

    ok $i->{C}->tag eq q(c);

    ok $i->{E}->tag eq q(e);

numberTreesJustIds($$)

Number the ids of the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source. You can see the numbers by printing the tree with prettyStringNumbered(). This method differs from numberTree in that only non text nodes without ids are numbered. The number applied to each node consists of the concatenation of the specified prefix, an underscore and a number that is unique within the specifed parse tree. Consequently the ids across several trees trees can be made unique by supplying different prefixes for each tree. Nodes can be found using findByNumber. Returns the specified $node.

     Parameter  Description
  1  $node      Node
  2  $prefix    Prefix for each id at and under the specified B<$node>

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>A
    <b id="bb">B
      <c/>
      <d>D
        <e id="ee"/>
          E
        <f/>
          F
      </d>
      G
    </b>
    H
  </a>
  END

    $a->𝗻𝘂𝗺𝗯𝗲𝗿𝗧𝗿𝗲𝗲𝘀𝗝𝘂𝘀𝘁𝗜𝗱𝘀(q(T));

    my $A = Data::Edit::Xml::new(<<END);
  <a id="T1">A
    <b id="bb">B
      <c id="T2"/>
      <d id="T3">D
        <e id="ee"/>
          E
        <f id="T4"/>
          F
      </d>
      G
    </b>
    H
  </a>
  END

    ok -p $a eq -p $A;

Forest Numbers

Number the nodes of several parse trees so that they can be easily retrieved by forest number - either by a person reading the source xml or programmatically.

forestNumberTrees($$)

Number the ids of the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source. You can see the numbers by printing the tree with prettyString. This method differs from numberTree in that only non text nodes are numbered and nodes with existing id= attributes have the value of their id= attribute transferred to a label. The number applied to each node consists of the concatenation of the specified tree number, an underscore and a number that is unique within the specified parse tree. Consequently the ids across several trees can be made unique by supplying a different tree number for each tree. Nodes can be found subsequently using findByForestNumber. Returns the specified $node.

     Parameter  Description
  1  $node      Node in parse tree to be numbered
  2  $prefix    Tree number

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b id="b">
      <c/>
    </b>
    <b id="B">
      <d/>
      <e/>
    </b>
  </a>
  END

    my $e = $a->go(qw(b -1 e));

    $e->𝗳𝗼𝗿𝗲𝘀𝘁𝗡𝘂𝗺𝗯𝗲𝗿𝗧𝗿𝗲𝗲𝘀(1);

    ok -p $a eq <<END;
  <a id="1_1">
    <b id="1_2">
      <c id="1_3"/>
    </b>
    <b id="1_4">
      <d id="1_5"/>
      <e id="1_6"/>
    </b>
  </a>
  END

findByForestNumber($$$)

Find the node with the specified forest number as made visible on the id attribute by prettyStringNumbered in the parse tree containing the specified $node and return the found node or undef if no such node exists.

     Parameter  Description
  1  $node      Node in the parse tree to search
  2  $tree      Forest number
  3  $id        Id number of the node required.

Example:

    ok -p $a eq <<END;
  <a id="1_1">
    <b id="1_2">
      <c id="1_3"/>
    </b>
    <b id="1_4">
      <d id="1_5"/>
      <e id="1_6"/>
    </b>
  </a>
  END

    my $B = $e->𝗳𝗶𝗻𝗱𝗕𝘆𝗙𝗼𝗿𝗲𝘀𝘁𝗡𝘂𝗺𝗯𝗲𝗿(1, 4);

    is_deeply [$B->getLabels], ["B"];

Order

Check the order and relative position of nodes in a parse tree.

above($$@)

Return the first node if the first node is above the second node optionally checking that the first node is in the specified context otherwise return undef

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $b->id eq 'b1';

    ok $e->id eq "e1";

    ok $E->id eq "e2";

    ok  $b->𝗮𝗯𝗼𝘃𝗲($e);

    ok !$E->𝗮𝗯𝗼𝘃𝗲($e);

abovePath($$)

Return the nodes along the path from the first node down to the second node when the first node is above the second node else return ().

     Parameter  Description
  1  $first     First node
  2  $second    Second node

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    my ($a, $b, $c, $d, $e) = $x->firstDown(@tags);

    is_deeply [$b, $d, $e], [$b->𝗮𝗯𝗼𝘃𝗲𝗣𝗮𝘁𝗵($e)];

    is_deeply [],   [$c->𝗮𝗯𝗼𝘃𝗲𝗣𝗮𝘁𝗵($d)];

below($$@)

Return the first node if the first node is below the second node optionally checking that the first node is in the specified context otherwise return undef

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $d->id eq 'd1';

    ok $e->id eq "e1";

    ok !$d->𝗯𝗲𝗹𝗼𝘄($e);

belowPath($$)

Return the nodes along the path from the first node up to the second node when the first node is below the second node else return ().

     Parameter  Description
  1  $first     First node
  2  $second    Second node

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    my ($a, $b, $c, $d, $e) = $x->firstDown(@tags);

    is_deeply [$e, $d, $b], [$e->𝗯𝗲𝗹𝗼𝘄𝗣𝗮𝘁𝗵($b)];

    is_deeply [$c], [$c->𝗯𝗲𝗹𝗼𝘄𝗣𝗮𝘁𝗵($c)];

after($$@)

Return the first node if it occurs after the second node in the parse tree optionally checking that the first node is in the specified context or else undef if the node is above, below or before the target.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $c->id eq 'c1';

    ok $e->id eq "e1";

    ok $e->𝗮𝗳𝘁𝗲𝗿($c);

before($$@)

Return the first node if it occurs before the second node in the parse tree optionally checking that the first node is in the specified context or else undef if the node is above, below or before the target.

     Parameter  Description
  1  $first     First node
  2  $second    Second node
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $e->id eq "e1";

    ok $E->id eq "e2";

    ok $e->𝗯𝗲𝗳𝗼𝗿𝗲($E);

disordered($@)

Return the first node that is out of the specified order when performing a pre-ordered traversal of the parse tree.

     Parameter  Description
  1  $node      Node
  2  @nodes     Following nodes.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $b->id eq 'b1';

    ok $c->id eq 'c1';

    ok $d->id eq 'd1';

    ok $e->id eq "e1";

    ok  $e->𝗱𝗶𝘀𝗼𝗿𝗱𝗲𝗿𝗲𝗱($c        )->id eq "c1";

    ok  $b->𝗱𝗶𝘀𝗼𝗿𝗱𝗲𝗿𝗲𝗱($c, $e, $d)->id eq "d1";

    ok !$c->𝗱𝗶𝘀𝗼𝗿𝗱𝗲𝗿𝗲𝗱($e);

commonAncestor($@)

Find the most recent common ancestor of the specified nodes or undef if there is no common ancestor.

     Parameter  Description
  1  $node      Node
  2  @nodes     @nodes

Example:

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="3">
        <e id="4"/>
      </c>
      <d id="5">
        <e id="6"/>
      </d>
      <c id="7">
        <d id="8">
          <e id="9"/>
        </d>
      </c>
      <d id="10">
        <e id="11"/>
      </d>
      <c id="12">
        <d id="13">
          <e id="14"/>
        </d>
      </c>
    </b>
  </a>
  END

     {my ($b, $e, @n) = $a->findByNumbers(2, 4, 6, 9);

      ok $e == $e->𝗰𝗼𝗺𝗺𝗼𝗻𝗔𝗻𝗰𝗲𝘀𝘁𝗼𝗿;

      ok $e == $e->𝗰𝗼𝗺𝗺𝗼𝗻𝗔𝗻𝗰𝗲𝘀𝘁𝗼𝗿($e);

      ok $b == $e->𝗰𝗼𝗺𝗺𝗼𝗻𝗔𝗻𝗰𝗲𝘀𝘁𝗼𝗿($b);

      ok $b == $e->𝗰𝗼𝗺𝗺𝗼𝗻𝗔𝗻𝗰𝗲𝘀𝘁𝗼𝗿(@n);

commonAdjacentAncestors($$)

Given two nodes, find a pair of adjacent ancestral siblings if such a pair exists else return ().

     Parameter  Description
  1  $first     First node
  2  $second    Second node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    is_deeply [$d->𝗰𝗼𝗺𝗺𝗼𝗻𝗔𝗱𝗷𝗮𝗰𝗲𝗻𝘁𝗔𝗻𝗰𝗲𝘀𝘁𝗼𝗿𝘀($C)], [$b, $B];

ordered($@)

Return the first node if the specified nodes are all in order when performing a pre-ordered traversal of the parse tree else return undef.

     Parameter  Description
  1  $node      Node
  2  @nodes     Following nodes.

Example:

    my $x = Data::Edit::Xml::new(<<END);
  <a       id='a1'>
    <b     id='b1'>
      <c   id='c1'/>
      <c   id='c2'/>
      <d   id='d1'>
        <e id='e1'/>
      </d>
      <c   id='c3'/>
      <c   id='c4'/>
      <d   id='d2'>
        <e id='e2'/>
      </d>
      <c   id='c5'/>
      <c   id='c6'/>
    </b>
  </a>
  END

    ok $e->id eq "e1";

    ok $E->id eq "e2";

    ok  $e->𝗼𝗿𝗱𝗲𝗿𝗲𝗱($E);

    ok !$E->𝗼𝗿𝗱𝗲𝗿𝗲𝗱($e);

    ok  $e->𝗼𝗿𝗱𝗲𝗿𝗲𝗱($e);

    ok  $e->𝗼𝗿𝗱𝗲𝗿𝗲𝗱;

Patching

Analyze two similar parse trees and create a patch that transforms the first parse tree into the second as long as each tree has the same tag and id structure with each id being unique.

createPatch($$)

Create a patch that moves the source parse tree to the target parse tree node as long as they have the same tag and id structure with each id being unique.

     Parameter  Description
  1  $a         Source parse tree
  2  $A         Target parse tree

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>Aaaaa
    <b b1="b1" b2="b2">Bbbbb
      <c c1="c1" />Ccccc
      <d d1="d1" >Ddddd
        <e  e1="e1" />
          Eeeee
        <f  f1="f1" />
          Fffff
      </d>
      Ggggg
    </b>
    Hhhhhh
  </a>
  END

    my $A = Data::Edit::Xml::new(<<END);
  <a>AaaAaaA
    <b b1="b1" b3="B3">BbbBbbB
      <c c1="C1" />Ccccc
      <d d2="D2" >DddDddD
        <e  e3="E3" />
          EeeEeeE
        <f  f1="F1" />
          FffFffF
      </d>
      GggGggG
    </b>
    Hhhhhh
  </a>
  END

    $a->numberTreesJustIds(q(a));

    $A->numberTreesJustIds(q(a));

    my $patches = $a->𝗰𝗿𝗲𝗮𝘁𝗲𝗣𝗮𝘁𝗰𝗵($A);

    $patches->install($a);

    ok !$a->diff  ($A);

    ok  $a->equals($A);

Data::Edit::Xml::Patch::install($$)

Replay a patch created by createPatch against a parse tree that has the same tag and id structure with each id being unique.

     Parameter  Description
  1  $patches   Patch
  2  $a         Parse tree

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>Aaaaa
    <b b1="b1" b2="b2">Bbbbb
      <c c1="c1" />Ccccc
      <d d1="d1" >Ddddd
        <e  e1="e1" />
          Eeeee
        <f  f1="f1" />
          Fffff
      </d>
      Ggggg
    </b>
    Hhhhhh
  </a>
  END

    my $A = Data::Edit::Xml::new(<<END);
  <a>AaaAaaA
    <b b1="b1" b3="B3">BbbBbbB
      <c c1="C1" />Ccccc
      <d d2="D2" >DddDddD
        <e  e3="E3" />
          EeeEeeE
        <f  f1="F1" />
          FffFffF
      </d>
      GggGggG
    </b>
    Hhhhhh
  </a>
  END

    $a->numberTreesJustIds(q(a));

    $A->numberTreesJustIds(q(a));

    my $patches = $a->createPatch($A);

    $patches->install($a);

    ok !$a->diff  ($A);

    ok  $a->equals($A);

Propogating

Propagate parent node attributes through a parse tree.

propagate($$@)

Propagate new attributes from nodes that match the specified tag to all their child nodes, then unwrap all the nodes that match the specified tag. Return the specified parse tree.

     Parameter  Description
  1  $tree      Parse tree
  2  $tag       Tag of nodes whose attributes are to be propagated
  3  @context   Optional context for parse tree

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b b="B">
      <b c="C">
        <c/>
        <b d="D">
          <d/>
          <b e="E">
            <e/>
          </b>
        </b>
      </b>
    </b>
  </a>
  END

    $a->𝗽𝗿𝗼𝗽𝗮𝗴𝗮𝘁𝗲(q(b));

    ok -p $a eq <<END;
  <a>
    <c b="B" c="C"/>
    <d b="B" c="C" d="D"/>
    <e b="B" c="C" d="D" e="E"/>
  </a>
  END

Table of Contents

Analyze and generate tables of contents.

tocNumbers($@)

Table of Contents number the nodes in a parse tree.

     Parameter  Description
  1  $node      Node
  2  @match     Optional list of tags to descend into else all tags will be descended into

Example:

    ok $a->prettyStringNumbered eq <<END;
  <a id="1">
    <b id="2">
      <A id="3"/>
      <B id="4"/>
    </b>
    <c id="5">
      <C id="6"/>
      <D id="7"/>
    </c>
  </a>
  END

      my $t = $a->𝘁𝗼𝗰𝗡𝘂𝗺𝗯𝗲𝗿𝘀();

      is_deeply {map {$_=>$t->{$_}->tag} keys %$t},

       {"1"  =>"b",

        "1 1"=>"A",

        "1 2"=>"B",

        "2"  =>"c",

        "2 1"=> "C",

        "2 2"=>"D"

       }

Labels

Label nodes so that they can be cross referenced and linked by Data::Edit::Xml::Lint

addLabels($@)

Add the named labels to the specified $node and return the number of labels added. Labels that are not defined will be ignored.

     Parameter  Description
  1  $node      Node in parse tree
  2  @labels    Names of labels to add.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b><c/></b></a>';

    my $b = $x->go(q(b));

    ok $b->countLabels == 0;

    $b->𝗮𝗱𝗱𝗟𝗮𝗯𝗲𝗹𝘀(1..2);

    $b->𝗮𝗱𝗱𝗟𝗮𝗯𝗲𝗹𝘀(3..4);

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c/></b></a>';

countLabels($)

Return the count of the number of labels at a node.

     Parameter  Description
  1  $node      Node in parse tree.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b><c/></b></a>';

    my $b = $x->go(q(b));

    ok $b->𝗰𝗼𝘂𝗻𝘁𝗟𝗮𝗯𝗲𝗹𝘀 == 0;

    $b->addLabels(1..2);

    $b->addLabels(3..4);

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c/></b></a>';

    ok $b->𝗰𝗼𝘂𝗻𝘁𝗟𝗮𝗯𝗲𝗹𝘀 == 4;

labelsInTree($)

Return a hash of all the labels in a tree

     Parameter  Description
  1  $tree      Parse tree.

Example:

    ok -p (new $A->stringExtendingIdsWithLabels) eq <<END;
  <a id="aa, a, a5">
    <b id="bb, b, b2">
      <c id="cc, c, c1"/>
    </b>
    <b id="B, b4">
      <c id="C, c3"/>
    </b>
  </a>
  END

    is_deeply [sort keys %{$A->𝗹𝗮𝗯𝗲𝗹𝘀𝗜𝗻𝗧𝗿𝗲𝗲}],

      ["B", "C", "a", "a5", "b", "b2", "b4", "c", "c1", "c3"];

getLabels($)

Return the names of all the labels set on a node.

     Parameter  Description
  1  $node      Node in parse tree.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b><c/></b></a>';

    my $b = $x->go(q(b));

    ok $b->countLabels == 0;

    $b->addLabels(1..2);

    $b->addLabels(3..4);

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c/></b></a>';

    is_deeply [1..4], [$b->𝗴𝗲𝘁𝗟𝗮𝗯𝗲𝗹𝘀];

deleteLabels($@)

Delete the specified labels in the specified $node or all labels if no labels have are specified and return that node.

     Parameter  Description
  1  $node      Node in parse tree
  2  @labels    Names of the labels to be deleted

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c id="1, 2, 3, 4"/></b></a>';

    $b->𝗱𝗲𝗹𝗲𝘁𝗲𝗟𝗮𝗯𝗲𝗹𝘀(1,4) for 1..2;

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="2, 3"><c id="1, 2, 3, 4"/></b></a>';

copyLabels($$)

Copy all the labels from the source node to the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c/></b></a>';

    $b->𝗰𝗼𝗽𝘆𝗟𝗮𝗯𝗲𝗹𝘀($c) for 1..2;

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="1, 2, 3, 4"><c id="1, 2, 3, 4"/></b></a>';

moveLabels($$)

Move all the labels from the source node to the target node and return the source node.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node.

Example:

    ok $x->stringReplacingIdsWithLabels eq '<a><b id="2, 3"><c id="1, 2, 3, 4"/></b></a>';

    $b->𝗺𝗼𝘃𝗲𝗟𝗮𝗯𝗲𝗹𝘀($c) for 1..2;

    ok $x->stringReplacingIdsWithLabels eq '<a><b><c id="1, 2, 3, 4"/></b></a>';

copyLabelsAndIdsInTree($$)

Copy all the labels and ids in the source parse tree to the matching nodes in the target parse tree. Nodes are matched via path. Return the number of labels and ids copied.

     Parameter  Description
  1  $source    Source node
  2  $target    Target node.

Example:

    ok -p (new $a->stringExtendingIdsWithLabels) eq <<END;
  <a id="a, a5">
    <b id="b, b2">
      <c id="c, c1"/>
    </b>
    <b id="B, b4">
      <c id="C, c3"/>
    </b>
  </a>
  END

    ok -p (new $A->stringExtendingIdsWithLabels) eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
    <b>
      <c/>
    </b>
  </a>
  END

    ok $a->𝗰𝗼𝗽𝘆𝗟𝗮𝗯𝗲𝗹𝘀𝗔𝗻𝗱𝗜𝗱𝘀𝗜𝗻𝗧𝗿𝗲𝗲($A) == 10;

    ok -p (new $A->stringExtendingIdsWithLabels) eq <<END;
  <a id="aa, a, a5">
    <b id="bb, b, b2">
      <c id="cc, c, c1"/>
    </b>
    <b id="B, b4">
      <c id="C, c3"/>
    </b>
  </a>
  END

giveEveryIdAGuid($$)

Give a guid to every node in the specified $tree that has an id attribute, saving any existing id attribute as a label, and return the count of the number of such replacements made.

     Parameter  Description
  1  $tree      Tree
  2  $genGuid   A sub that accepts a number and a node and returns a new Guid each time it is called

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a id="a">
    <b id="b">
      <c id="c"/>
    </b>
    <d/>
  </a>
  END
    my $n  =0;
    $a->𝗴𝗶𝘃𝗲𝗘𝘃𝗲𝗿𝘆𝗜𝗱𝗔𝗚𝘂𝗶𝗱(sub
     {my ($n, $o) = @_;
      qq(GUID-$n)
     });

    ok -p $a eq <<END;
  <a id="GUID-3">
    <b id="GUID-2">
      <c id="GUID-1"/>
    </b>
    <d/>
  </a>
  END

   ok $a->stringReplacingIdsWithLabels eq q(<a id="a"><b id="b"><c id="c"/></b><d/></a>);
   ok $a->stringExtendingIdsWithLabels eq q(<a id="GUID-3, a"><b id="GUID-2, b"><c id="GUID-1, c"/></b><d/></a>);

   }

createGuidId($)

Create an id for the specified $node from the md5Sum of its content moving any existing id to the labels associated with the $node and return the existing $node.

     Parameter  Description
  1  $node      Node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      c
    </b>
  </a>
  END

    ok $a->𝗰𝗿𝗲𝗮𝘁𝗲𝗚𝘂𝗶𝗱𝗜𝗱->id eq q(GUID-390bf05d-8f56-71cc-6a47-71834840d695);
   }

Operators

Operator access to methods use the assign versions to avoid 'useless use of operator in void context' messages. Use the non assign versions to return the results of the underlying method call. Thus '/' returns the wrapping node, whilst '/=' does not. Assign operators always return their left hand side even though the corresponding method usually returns the modification on the right.

opString($$)

-B: bitsNodeTextBlank

-b: isAllBlankText

-c: context

-e: prettyStringEnd

-f: first node

-g: pathString

-l: last node

-M: number

-o: contentAsTags

-p: prettyString

-s: string

-S : stringNode

-T : isText

-t : tag

-u: id

-W: unWrap

-w: stringQuoted

-x: prettyStringDitaHeaders

-X: cut

-z: prettyStringNumbered.

     Parameter  Description
  1  $node      Node
  2  $op        Monadic operator.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b><c>ccc</c></b>
    <d><e>eee</e></d>
  </a>
  END

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    my ($c, $b, $e, $d) = $a->byList;

    ok $c->printNode eq q(c id="42" match="mm");

    ok -A $c eq q(c id="42" match="mm");

    ok -b $e;

    ok -c $e eq q(e d a);

    ok -f $b eq $c;

    ok -l $a eq $d;

    ok -O $a, q( b  d );

    ok -o $a, q(b d);

    ok -w $a eq q('<a><b><c id="42" match="mm"/></b><d><e/></d></a>');

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok -s $a eq '<a><b><c id="42" match="mm"/></b><d><e/></d></a>';

    ok -t $a eq 'a';

    $a->numberTree;

    ok -z $a eq <<END;
  <a id="1">
    <b id="2">
      <c id="42" match="mm"/>
    </b>
    <d id="4">
      <e id="5"/>
    </d>
  </a>
  END

   {my $a = Data::Edit::Xml::new(<<END);
  <concept/>
  END

    Data::Edit::Xml::ditaOrganization = q(ACT);

    ok $a->prettyStringDitaHeaders eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

    ok -x $a eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

opContents($)

@{} : nodes immediately below a node.

     Parameter  Description
  1  $node      Node.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b><c>ccc</c></b>
    <d><e>eee</e></d>
  </a>
  END

    my ($b, $d) =  @$a;

    ok -c $b eq q(b a);

    my ($c)     =  @$b;

    ok -c $c eq q(c b a);

opAt($$)

<= : Check that a node is in the context specified by the referenced array of words.

     Parameter  Description
  1  $node      Node
  2  $context   Reference to array of words specifying the parents of the desired node.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok (($a >= [qw(d e)]) <= [qw(e d a)]);

opNew($$)

** : create a new node from the text on the right hand side: if the text contains a non word character \W the node will be create as text, else it will be created as a tag

     Parameter  Description
  1  $node      Node
  2  $text      Name node of node to create or text of new text element

Example:

   {my $a = Data::Edit::Xml::new("<a/>");

    my $b = $a ** q(b);

    ok -s $b eq "<b/>";

opPutFirst($$)

>> : put a node or string first under a node and return the new node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place first under the node.

Example:

    ok -p $a eq <<END;
  <a/>
  END

    my $f = $a >> qq(first);

    ok -p $a eq <<END;
  <a>
    <first/>
  </a>
  END

opPutFirstAssign($$)

>>= : put a node or string first under a node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place first under the node.

Example:

    ok -p $a eq <<END;
  <a/>
  END

    $a >>= qq(first);

    ok -p $a eq <<END;
  <a>
    <first/>
  </a>
  END

opPutLast($$)

<< : put a node or string last under a node and return the new node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place last under the node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
  </a>
  END

    my $l = $a << qq(last);

    ok -p $a eq <<END;
  <a>
    <first/>
    <last/>
  </a>
  END

opPutLastAssign($$)

<<= : put a node or string last under a node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place last under the node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
  </a>
  END

    $a <<= qq(last);

    ok -p $a eq <<END;
  <a>
    <first/>
    <last/>
  </a>
  END

opPutNext($$)

> + : put a node or string after the specified $node and return the new node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place after the first node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
    <last/>
  </a>
  END

    $f += qq(next);

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <last/>
  </a>
  END

opPutNextAssign($$)

+= : put a node or string after the specified $node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place after the first node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
    <last/>
  </a>
  END

    my $f = -f $a;

    $f += qq(next);

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <last/>
  </a>
  END

opPutPrev($$)

< - : put a node or string before the specified $node and return the new node.

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place before the first node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <last/>
  </a>
  END

    $l -= qq(prev);

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <prev/>
    <last/>
  </a>
  END

opPutPrevAssign($$)

-= : put a node or string before the specified $node,

     Parameter  Description
  1  $node      Node
  2  $text      Node or text to place before the first node.

Example:

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <last/>
  </a>
  END

    my $l = -l $a;

    $l -= qq(prev);

    ok -p $a eq <<END;
  <a>
    <first/>
    <next/>
    <prev/>
    <last/>
  </a>
  END

opBy($$)

x= : Traverse a parse tree in post-order.

     Parameter  Description
  1  $node      Parse tree
  2  $code      Code to execute against each node.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

     {my $s; $a x= sub{$s .= -t $_}; ok $s eq "cbeda"

opGo($$)

>= : Search for a node via a specification provided as a reference to an array of words each number. Each word represents a tag name, each number the index of the previous tag or zero by default.

     Parameter  Description
  1  $node      Node
  2  $go        Reference to an array of search parameters.

Example:

    ok -p $a eq <<END;
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok (($a >= [qw(d e)]) <= [qw(e d a)]);

opAttr($$)

% : Get the value of an attribute of the specified $node.

     Parameter  Description
  1  $node      Node
  2  $attr      Reference to an array of words and numbers specifying the node to search for.

Example:

   {my $a = Data::Edit::Xml::new('<a number="1"/>');

    ok $a %  qq(number) == 1;

opWrapWith($$)

/ : Wrap node with a tag, returning the wrapping node.

     Parameter  Description
  1  $node      Node
  2  $tag       Tag.

Example:

   {my $c = Data::Edit::Xml::new("<c/>");

    my $b = $c / qq(b);

    ok -s $b eq "<b><c/></b>";

    my $a = $b / qq(a);

    ok -s $a eq "<a><b><c/></b></a>";

opWrapContentWith($$)

* : Wrap content with a tag, returning the wrapping node.

     Parameter  Description
  1  $node      Node
  2  $tag       Tag.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $b *= q(B);

    ok -p $a eq <<END;
  <a>
    <b>
      <B>
        <c/>
        <d/>
      </B>
    </b>
  </a>
  END

opCut($)

-- : Cut out a node.

     Parameter  Description
  1  $node      Node.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>
    <b><c/></b>
  </a>
  END

    my $b = $x >= qq(b);

     --$b;

    ok -s $x eq "<a/>";

    ok -s $b eq "<b><c/></b>";

opUnwrap($)

++ : Unwrap a node.

     Parameter  Description
  1  $node      Node.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
      <d/>
    </b>
  </a>
  END

    my ($c, $d, $b) = $a->byList;

    $b++;

    ok -p $a eq <<END;
  <a>
    <c/>
    <d/>
  </a>
  END

Statistics

Statistics describing the parse tree.

count($@)

Return the count of the number of instances of the specified tags under the specified $node, either by tag in array context or in total in scalar context.

     Parameter  Description
  1  $node      Node
  2  @names     Possible tags immediately under the node.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a>

  </a>
  END

    ok $x->𝗰𝗼𝘂𝗻𝘁 == 0;

countTags($)

Count the number of tags in a parse tree.

     Parameter  Description
  1  $node      Parse tree.

Example:

      ok -p $a eq <<END;
  <a id="aa">
    <b id="bb">
      <c id="cc"/>
    </b>
  </a>
  END

      ok $a->𝗰𝗼𝘂𝗻𝘁𝗧𝗮𝗴𝘀 == 3;

countTagNames($$)

Return a reference to a hash showing the number of instances of each tag on and below the specified $node.

     Parameter  Description
  1  $node      Node
  2  $count     Count of tags so far.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a A="A" B="B" C="C">
    <b  B="B" C="C">
      <c  C="C">
      </c>
      <c/>
    </b>
    <b  C="C">
      <c/>
    </b>
  </a>
  END

    is_deeply $x->𝗰𝗼𝘂𝗻𝘁𝗧𝗮𝗴𝗡𝗮𝗺𝗲𝘀,  { a => 1, b => 2, c => 3 };

countAttrNames($$)

Return a reference to a hash showing the number of instances of each attribute on and below the specified $node.

     Parameter  Description
  1  $node      Node
  2  $count     Attribute count so far

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a A="A" B="B" C="C">
    <b  B="B" C="C">
      <c  C="C">
      </c>
      <c/>
    </b>
    <b  C="C">
      <c/>
    </b>
  </a>
  END

    is_deeply $x->𝗰𝗼𝘂𝗻𝘁𝗔𝘁𝘁𝗿𝗡𝗮𝗺𝗲𝘀, { A => 1, B => 2, C => 4 };

countAttrNamesOnTagExcluding($@)

Count the number of attributes owned by the specified $node that are not in the specified list.

     Parameter  Description
  1  $node      Node
  2  @attr      Attributes to ignore

Example:

   {my $a = Data::Edit::Xml::new(q(<a a="1" b="2" c="3" d="4" e="5"/>));

countAttrValues($$)

Return a reference to a hash showing the number of instances of each attribute value on and below the specified $node.

     Parameter  Description
  1  $node      Node
  2  $count     Count of attributes so far.

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <a A="A" B="B" C="C">
    <b  B="B" C="C">
      <c  C="C">
      </c>
      <c/>
    </b>
    <b  C="C">
      <c/>
    </b>
  </a>
  END

    is_deeply $x->𝗰𝗼𝘂𝗻𝘁𝗔𝘁𝘁𝗿𝗩𝗮𝗹𝘂𝗲𝘀, { A => 1, B => 2, C => 4 };

countOutputClasses($$)

Count instances of outputclass attributes

     Parameter  Description
  1  $node      Node
  2  $count     Count so far.

Example:

   {my $a = Data::Edit::Xml::newTree("a", id=>1, class=>2, href=>3, outputclass=>4);

    is_deeply { 4 => 1 }, $a->𝗰𝗼𝘂𝗻𝘁𝗢𝘂𝘁𝗽𝘂𝘁𝗖𝗹𝗮𝘀𝘀𝗲𝘀;

changeReasonCommentSelectionSpecification()

Provide a specification to select change reason comments to be inserted as text into a parse tree. A specification can be either:

the name of a code to be accepted,
a regular expression which matches the codes to be accepted,
a hash whose keys are defined for the codes to be accepted or
undef (the default) to specify that no such comments should be accepted.

Example:

    𝗰𝗵𝗮𝗻𝗴𝗲𝗥𝗲𝗮𝘀𝗼𝗻𝗖𝗼𝗺𝗺𝗲𝗻𝘁𝗦𝗲𝗹𝗲𝗰𝘁𝗶𝗼𝗻𝗦𝗽𝗲𝗰𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 = {ccc=>1, ddd=>1};

    𝗰𝗵𝗮𝗻𝗴𝗲𝗥𝗲𝗮𝘀𝗼𝗻𝗖𝗼𝗺𝗺𝗲𝗻𝘁𝗦𝗲𝗹𝗲𝗰𝘁𝗶𝗼𝗻𝗦𝗽𝗲𝗰𝗶𝗳𝗶𝗰𝗮𝘁𝗶𝗼𝗻 = undef;

This is a static method and so should be invoked as:

  Data::Edit::Xml::changeReasonCommentSelectionSpecification

crc($$$)

Insert a comment consisting of a code and an optional reason as text into the parse tree to indicate the location of changes to the parse tree. As such comments tend to become very numerous, only comments whose codes matches the specification provided in changeReasonCommentSelectionSpecification are accepted for insertion. Subsequently these comments can be easily located using:

grep -nr "<!--code"

on the file containing a printed version of the parse tree. Please note that these comments will be removed if the output file is reparsed.

Returns the specified $node.

     Parameter  Description
  1  $node      Node being changed
  2  $code      Reason code
  3  $reason    Optional text description of change

Example:

   {my $a = Data::Edit::Xml::new("<a><b/></a>");

    my ($b) = $a->contents;

    changeReasonCommentSelectionSpecification = {ccc=>1, ddd=>1};

    $b->putFirst(my $c = $b->newTag(q(c)));

    $c->𝗰𝗿𝗰($_) for qw(aaa ccc);

    ok <<END eq -p $a;
  <a>
    <b><!--ccc-->
      <c/>
    </b>
  </a>
  END

    changeReasonCommentSelectionSpecification = undef;

    $c->putFirst(my $d = $c->newTag(q(d)));

    $d->𝗰𝗿𝗰($_) for qw(aaa ccc);

    ok <<END eq -p $a;
  <a>
    <b><!--ccc-->
      <c>
        <d/>
      </c>
    </b>
  </a>
  END

howFirst($)

Return the depth to which the specified $node is first else 0.

     Parameter  Description
  1  $node      Node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok $d->𝗵𝗼𝘄𝗙𝗶𝗿𝘀𝘁     == 4;

howLast($)

Return the depth to which the specified $node is last else 0.

     Parameter  Description
  1  $node      Node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok $f->𝗵𝗼𝘄𝗟𝗮𝘀𝘁      == 3;

howOnlyChild($)

Return the depth to which the specified $node is an only child else 0.

     Parameter  Description
  1  $node      Node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok $d->𝗵𝗼𝘄𝗢𝗻𝗹𝘆𝗖𝗵𝗶𝗹𝗱 == 2;

howFar($$)

Return how far the first node is from the second node along a path through their common ancestor.

     Parameter  Description
  1  $first     First node
  2  $second    Second node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    is_deeply [$d->commonAdjacentAncestors($C)], [$b, $B];

    ok $d->𝗵𝗼𝘄𝗙𝗮𝗿($d) == 0;

    ok $d->𝗵𝗼𝘄𝗙𝗮𝗿($a) == 3;

    ok $b->𝗵𝗼𝘄𝗙𝗮𝗿($B) == 1;

    ok $d->𝗵𝗼𝘄𝗙𝗮𝗿($f) == 5;

    ok $d->𝗵𝗼𝘄𝗙𝗮𝗿($C) == 4;

howFarAbove($$)

Return how far the first node is above the second node is or 0 if the first node is not strictly above the second node.

     Parameter  Description
  1  $above     First node above
  2  $below     Second node below

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok  $a->𝗵𝗼𝘄𝗙𝗮𝗿𝗔𝗯𝗼𝘃𝗲($d) == 3;

    ok !$d->𝗵𝗼𝘄𝗙𝗮𝗿𝗔𝗯𝗼𝘃𝗲($c);

howFarBelow($$)

Return how far the first node is below the second node is or 0 if the first node is not strictly below the second node.

     Parameter  Description
  1  $below     First node below
  2  $above     Second node above

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
    </b>
    <b>
      <c/>
    </b>
    <e>
      <f/>
    </e>
  </a>
  END

    my ($d, $c, $b, $C, $B, $f, $e) = $a->byList;

    ok  $d->𝗵𝗼𝘄𝗙𝗮𝗿𝗕𝗲𝗹𝗼𝘄($a) == 3;

    ok !$c->𝗵𝗼𝘄𝗙𝗮𝗿𝗕𝗲𝗹𝗼𝘄($d);

Required clean up

Insert required clean up tags.

requiredCleanUp($$)

Replace a node with a required cleanup node around the text of the replaced node with special characters replaced by symbols.

Returns the specified $node.

     Parameter     Description
  1  $node         Node
  2  $outputclass  Optional outputclass attribute of required cleanup tag

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        ccc
      </c>
    </b>
  </a>
  END

    my ($b) = $a->contents;

    $b->𝗿𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(q(33));

    ok -p $a eq <<END;
  <a>
    <required-cleanup outputclass="33">&lt;b&gt;
    &lt;c&gt;
        ccc
      &lt;/c&gt;
  &lt;/b&gt;
  </required-cleanup>
  </a>
  END

replaceWithRequiredCleanUp($$)

Replace a node with a required cleanup message and return the new node

     Parameter  Description
  1  $node      Node to be replace
  2  $text      Clean up message

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
  </a>
  END

    my ($b) = $a->contents;

    $b->𝗿𝗲𝗽𝗹𝗮𝗰𝗲𝗪𝗶𝘁𝗵𝗥𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(q(bb));

    ok -p $a eq <<END;
  <a>
    <required-cleanup>bb</required-cleanup>
  </a>
  END

putFirstRequiredCleanUp($$)

Place a required cleanup tag first under a node and return the required clean up node.

     Parameter  Description
  1  $node      Node
  2  $text      Clean up message

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b/>
  </a>
  END

    $a->𝗽𝘂𝘁𝗙𝗶𝗿𝘀𝘁𝗥𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(qq(1111
));

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
  </a>
  END

putLastRequiredCleanUp($$)

Place a required cleanup tag last under a node and return the required clean up node.

     Parameter  Description
  1  $node      Node
  2  $text      Clean up message

Example:

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
  </a>
  END

    $a->𝗽𝘂𝘁𝗟𝗮𝘀𝘁𝗥𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(qq(4444
));

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
    <required-cleanup>4444
  </required-cleanup>
  </a>
  END

putNextRequiredCleanUp($$)

Place a required cleanup tag after a node.

     Parameter  Description
  1  $node      Node
  2  $text      Clean up message

Example:

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
    <required-cleanup>4444
  </required-cleanup>
  </a>
  END

    $a->go(q(b))->𝗽𝘂𝘁𝗡𝗲𝘅𝘁𝗥𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(qq(3333
));

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
    <required-cleanup>3333
  </required-cleanup>
    <required-cleanup>4444
  </required-cleanup>
  </a>
  END

putPrevRequiredCleanUp($$)

Place a required cleanup tag before a node.

     Parameter  Description
  1  $node      Node
  2  $text      Clean up message

Example:

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <b/>
    <required-cleanup>3333
  </required-cleanup>
    <required-cleanup>4444
  </required-cleanup>
  </a>
  END

    $a->go(q(b))->𝗽𝘂𝘁𝗣𝗿𝗲𝘃𝗥𝗲𝗾𝘂𝗶𝗿𝗲𝗱𝗖𝗹𝗲𝗮𝗻𝗨𝗽(qq(2222
));

    ok -p $a eq <<END;
  <a>
    <required-cleanup>1111
  </required-cleanup>
    <required-cleanup>2222
  </required-cleanup>
    <b/>
    <required-cleanup>3333
  </required-cleanup>
    <required-cleanup>4444
  </required-cleanup>
  </a>
  END

Conversions

Methods useful for conversions to and from word, html and Dita.

ditaListToChoices($@)

Change the specified $list to choices.

     Parameter  Description
  1  $list      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <ol>
    <li>
      <p/>
    </li>
    <li>
      <p/>
    </li>
  </ol>
  END

    $a->𝗱𝗶𝘁𝗮𝗟𝗶𝘀𝘁𝗧𝗼𝗖𝗵𝗼𝗶𝗰𝗲𝘀;
    ok -p $a eq <<END;
  <choices>
    <choice>
      <p/>
    </choice>
    <choice>
      <p/>
    </choice>
  </choices>
  END
   }

ditaListToSteps($@)

Change the specified $node to steps and its contents to cmd\step optionally only in the specified context.

     Parameter  Description
  1  $list      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $a eq <<END;
  <dita>
    <ol>
      <li>
        <p>aaa</p>
      </li>
      <li>
        <p>bbb</p>
      </li>
    </ol>
  </dita>
  END

    $a->first->𝗱𝗶𝘁𝗮𝗟𝗶𝘀𝘁𝗧𝗼𝗦𝘁𝗲𝗽𝘀;

    ok -p $a eq <<END;
  <dita>
    <steps>
      <step>
        <cmd>aaa</cmd>
      </step>
      <step>
        <cmd>bbb</cmd>
      </step>
    </steps>
  </dita>
  END

ditaListToStepsUnordered($@)

Change the specified $node to steps-unordered and its contents to cmd\step optionally only in the specified context.

     Parameter  Description
  1  $list      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $a eq <<END;
  <dita>
    <ol>
      <li>aaa</li>
      <li>bbb</li>
    </ol>
  </dita>
  END

    $a->first->𝗱𝗶𝘁𝗮𝗟𝗶𝘀𝘁𝗧𝗼𝗦𝘁𝗲𝗽𝘀𝗨𝗻𝗼𝗿𝗱𝗲𝗿𝗲𝗱;

    ok -p $a eq <<END;
  <dita>
    <steps-unordered>
      <step>
        <cmd>aaa</cmd>
      </step>
      <step>
        <cmd>bbb</cmd>
      </step>
    </steps-unordered>
  </dita>
  END

ditaListToSubSteps($@)

Change the specified $node to substeps and its contents to cmd\step optionally only in the specified context.

     Parameter  Description
  1  $list      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <dita>
    <ol>
      <li>aaa</li>
      <li>bbb</li>
    </ol>
  </dita>
  END

    $a->first->𝗱𝗶𝘁𝗮𝗟𝗶𝘀𝘁𝗧𝗼𝗦𝘂𝗯𝗦𝘁𝗲𝗽𝘀;

    ok -p $a eq <<END;
  <dita>
    <substeps>
      <substep>
        <cmd>aaa</cmd>
      </substep>
      <substep>
        <cmd>bbb</cmd>
      </substep>
    </substeps>
  </dita>
  END

ditaStepsToList($$@)

Change the specified $node to a node with name $tag or to ol if $tag is not supplied and its cmd\step content to li to create a list optionally only in the specified context.

     Parameter  Description
  1  $steps     Node
  2  $tag       New tag if not ol
  3  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

    ok -p $a eq <<END;
  <dita>
    <ol>
      <li>
        <p>aaa</p>
      </li>
      <li>
        <p>bbb</p>
      </li>
    </ol>
  </dita>
  END

    $a->first->𝗱𝗶𝘁𝗮𝗦𝘁𝗲𝗽𝘀𝗧𝗼𝗟𝗶𝘀𝘁;

    ok -p $a eq <<END;
  <dita>
    <ol>
      <li>aaa</li>
      <li>bbb</li>
    </ol>
  </dita>
  END

ditaStepsToChoices($@)

Change the specified $node to choices.

     Parameter  Description
  1  $steps     Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <steps>
    <step>
      <cmd>Command</cmd>
      <stepresult>
  Step result
  </stepresult>
      <stepxmp>
  Step example
  </stepxmp>
    </step>
    <step>
      <cmd>Command</cmd>
      <stepresult>
  Step result
  </stepresult>
      <stepxmp>
  Step example
  </stepxmp>
    </step>
  </steps>
  END

    $a->𝗱𝗶𝘁𝗮𝗦𝘁𝗲𝗽𝘀𝗧𝗼𝗖𝗵𝗼𝗶𝗰𝗲𝘀;

    ok -p $a eq <<END;
  <choices>
    <choice>
      <p>Command</p>

  Step result

  Step example

    </choice>
    <choice>
      <p>Command</p>

  Step result

  Step example

    </choice>
  </choices>
  END
   }

ditaListToTable($@)

Convert a list to a table in situ - as designed by MiM.

     Parameter  Description
  1  $node      List node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <ul id="Table3" outputclass="fcRowList">
      <li>
          <p id="1">1111</p>
          <p id="2">2222</p>
          <p id="3">3333</p>
          <p id="4">4444</p>
      </li>
      <li>
          <p id="tableToListA1" outputclass="1">aaaa1111</p>
          <p id="tableToListA2" outputclass="1">aaaa2222</p>
          <p id="tableToListA3" outputclass="1">aaaa3333</p>
          <p id="tableToListA4" outputclass="1">aaaa4444</p>
      </li>
      <li>
          <p id="tableToListB1" outputclass="1">bbbb1111</p>
          <p id="tableToListB2" outputclass="1">bbbb2222</p>
          <p id="tableToListB3" outputclass="1">bbbb3333</p>
      </li>
      <li>
          <p id="tableToListC1" outputclass="1">cccc1111</p>
          <p id="tableToListC2" outputclass="1">cccc2222</p>
          <p id="tableToListC3" outputclass="1">cccc3333</p>
          <p id="tableToListC4" outputclass="1">cccc4444</p>
          <p id="tableToListC5" outputclass="1">cccc5555</p>
      </li>
  </ul>
  END
    $a->𝗱𝗶𝘁𝗮𝗟𝗶𝘀𝘁𝗧𝗼𝗧𝗮𝗯𝗹𝗲;
    ok nws(-p $a) eq nws(<<END)
  <table id="Table3" outputclass="fcRowList">
    <tgroup cols="5">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <colspec colname="c3" colnum="3" colwidth="1*"/>
      <colspec colname="c4" colnum="4" colwidth="1*"/>
      <colspec colname="c5" colnum="5" colwidth="1*"/>
      <thead>
        <row>
          <entry/>
          <entry/>
          <entry/>
          <entry/>
          <entry/>
        </row>
      </thead>
      <tbody>
        <row>
          <entry id="1">1111</entry>
          <entry id="2">2222</entry>
          <entry id="3">3333</entry>
          <entry id="4">4444</entry>
        </row>
        <row>
          <entry id="tableToListA1" outputclass="1">aaaa1111</entry>
          <entry id="tableToListA2" outputclass="1">aaaa2222</entry>
          <entry id="tableToListA3" outputclass="1">aaaa3333</entry>
          <entry id="tableToListA4" outputclass="1">aaaa4444</entry>
        </row>
        <row>
          <entry id="tableToListB1" outputclass="1">bbbb1111</entry>
          <entry id="tableToListB2" outputclass="1">bbbb2222</entry>
          <entry id="tableToListB3" outputclass="1">bbbb3333</entry>
        </row>
        <row>
          <entry id="tableToListC1" outputclass="1">cccc1111</entry>
          <entry id="tableToListC2" outputclass="1">cccc2222</entry>
          <entry id="tableToListC3" outputclass="1">cccc3333</entry>
          <entry id="tableToListC4" outputclass="1">cccc4444</entry>
          <entry id="tableToListC5" outputclass="1">cccc5555</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END
   }

ditaMergeLists($@)

Merge the specified $node with the preceding or following list or steps or substeps if possible and return the specified $node regardless.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <li id="1"/>
    <ol/>
    <ol>
      <li id="2"/>
      <li id="3"/>
    </ol>
  </a>
  END

    $a x= sub{$_->𝗱𝗶𝘁𝗮𝗠𝗲𝗿𝗴𝗲𝗟𝗶𝘀𝘁𝘀};

    ok -p $a eq <<END;
  <a>
    <ol>
      <li id="1"/>
      <li id="2"/>
      <li id="3"/>
    </ol>
  </a>
  END

mergeLikeElements($@)

Merge two of the same elements into one, retaining the order of any children. Return the original $node if the request succeeds, else return undef.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <x><a>aa</a><b>bb</b><b>dd</b></x>
  END

    ok -p $a eq <<END;
  <x>
    <a>aa</a>
    <b>bb</b>
    <b>dd</b>
  </x>
  END

    $a->go_b->𝗺𝗲𝗿𝗴𝗲𝗟𝗶𝗸𝗲𝗘𝗹𝗲𝗺𝗲𝗻𝘁𝘀;

    ok -p $a eq <<END;
  <x>
    <a>aa</a>
    <b>bbdd</b>
  </x>
  END

   }

mergeLikeNext($@)

Merge a $node in an optional context with the next node if the two have the same tag by placing the next node first in the current $node and unwrapping the next node. Return undef if the request fails else the current $node. Identical to mergeLikeElements

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb</b>
    <b>dd</b>
  </a>
  END

    $a->first->𝗺𝗲𝗿𝗴𝗲𝗟𝗶𝗸𝗲𝗡𝗲𝘅𝘁;

    ok -p $a eq <<END;
  <a>
    <b>bbdd</b>
  </a>
  END
   }

mergeLikePrev($@)

Merge a $node in an optional context with the previous node if the two have the same tag by placing the previous node first in the current $node and unwrapping the previous node. Return undef if the request fails else the current $node.

     Parameter  Description
  1  $node      Node
  2  @context   Optional context

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>bb</b>
    <b>dd</b>
  </a>
  END

    $a->last->𝗺𝗲𝗿𝗴𝗲𝗟𝗶𝗸𝗲𝗣𝗿𝗲𝘃;

    ok -p $a eq <<END;
  <a>
    <b>bbdd</b>
  </a>
  END
   }

ditaMaximumNumberOfEntriesInATGroupRow($)

Return the maximum number of entries in the rows of the specified $table or undef if not a table.

     Parameter  Description
  1  $tgroup    TGroup node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    ok $g->𝗱𝗶𝘁𝗮𝗠𝗮𝘅𝗶𝗺𝘂𝗺𝗡𝘂𝗺𝗯𝗲𝗿𝗢𝗳𝗘𝗻𝘁𝗿𝗶𝗲𝘀𝗜𝗻𝗔𝗧𝗚𝗿𝗼𝘂𝗽𝗥𝗼𝘄 == 3;

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 3,
    maxBodyMinusPadding => 3,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 1,
    minHead => 1,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->ditaRemoveTGroupTrailingEmptyEntries;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END
   }

ditaTGroupStatistics($)

Return statistics about the rows in a given table

     Parameter  Description
  1  $tgroup    Table group node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    ok $g->ditaMaximumNumberOfEntriesInATGroupRow == 3;

    is_deeply $g->𝗱𝗶𝘁𝗮𝗧𝗚𝗿𝗼𝘂𝗽𝗦𝘁𝗮𝘁𝗶𝘀𝘁𝗶𝗰𝘀,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 3,
    maxBodyMinusPadding => 3,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 1,
    minHead => 1,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->ditaRemoveTGroupTrailingEmptyEntries;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END
   }

ditaAddColSpecToTGroup($$)

Add the specified $number of column specification to a specified $tgroup which does not have any already.

     Parameter  Description
  1  $tgroup    Tgroup node
  2  $number    Number of colspecs to add

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup>
      <tbody>
        <row><entry/></row>
        <row><entry/><entry/></row>
        <row><entry/><entry/><entry/></row>
        <row><entry/><entry/></row>
        <row/>
      </tbody>
    </tgroup>
  </table>
  END

    ok 3 == $a->go_tgroup->ditaMaximumNumberOfEntriesInATGroupRow;
    $a->first->𝗱𝗶𝘁𝗮𝗔𝗱𝗱𝗖𝗼𝗹𝗦𝗽𝗲𝗰𝗧𝗼𝗧𝗚𝗿𝗼𝘂𝗽(3);

    ok -p $a eq <<END
  <table>
    <tgroup cols="3">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <colspec colname="c3" colnum="3" colwidth="1*"/>
      <tbody>
        <row>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
        </row>
        <row/>
      </tbody>
    </tgroup>
  </table>
  END
   }

ditaFixTGroupColSpec($)

Fix the colspec attribute and colspec nodes of the specified $tgroup.

     Parameter  Description
  1  $tgroup    Tgroup node

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup>
      <tbody>
        <row><entry/></row>
        <row><entry/><entry/></row>
        <row><entry/><entry/><entry/></row>
        <row><entry/><entry/></row>
        <row>
          <entry>
            <table>
              <tbody>
                <row><entry/><entry/><entry/><entry/><entry/><entry/><entry/></row>
              </tbody>
            </table>
          </entry>
        </row>
     </tbody>
   </tgroup>
  </table>
  END

    $a->go_tgroup->𝗱𝗶𝘁𝗮𝗙𝗶𝘅𝗧𝗚𝗿𝗼𝘂𝗽𝗖𝗼𝗹𝗦𝗽𝗲𝗰;

    ok -p $a eq <<END
  <table>
    <tgroup cols="3">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <colspec colname="c3" colnum="3" colwidth="1*"/>
      <tbody>
        <row>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry>
            <table>
              <tbody>
                <row>
                  <entry/>
                  <entry/>
                  <entry/>
                  <entry/>
                  <entry/>
                  <entry/>
                  <entry/>
                </row>
              </tbody>
            </table>
          </entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END
   }

ditaRemoveTGroupTrailingEmptyEntries($)

Remove empty trailing entry

     Parameter  Description
  1  $tgroup    Table node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    ok $g->ditaMaximumNumberOfEntriesInATGroupRow == 3;

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 3,
    maxBodyMinusPadding => 3,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 1,
    minHead => 1,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->𝗱𝗶𝘁𝗮𝗥𝗲𝗺𝗼𝘃𝗲𝗧𝗚𝗿𝗼𝘂𝗽𝗧𝗿𝗮𝗶𝗹𝗶𝗻𝗴𝗘𝗺𝗽𝘁𝘆𝗘𝗻𝘁𝗿𝗶𝗲𝘀;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END
   }

fixTGroup($)

Fix the specified $tgroup so that each row has the same number of entries with this number reflected in the tgroup.cols= attribute and colspec nodes.

     Parameter  Description
  1  $tgroup    TGroup node

Use the optional @context parameter to test the context of the specified $node as understood by method at. If the context is supplied and $node is not in this context then this method returns undef immediately.

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    $g->ditaAddPadEntriesToTGroupRows(2);

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->𝗳𝗶𝘅𝗧𝗚𝗿𝗼𝘂𝗽;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="2">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
          <entry/>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
          <entry/>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $a->fixTable;
    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

   }

fixTable($)

Fix the specified $table so that each row has the same number of entries with this number reflected in the tgroup.cols= attribute and colspec nodes.

     Parameter  Description
  1  $table     Table node

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    $g->ditaAddPadEntriesToTGroupRows(2);

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->fixTGroup;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="2">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
          <entry/>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
          <entry/>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $a->𝗳𝗶𝘅𝗧𝗮𝗯𝗹𝗲;
    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

   }

ditaObviousChanges($)

Make obvious changes to a parse tree to make it look more like Dita.

     Parameter  Description
  1  $node      Node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <dita>
    <ol>
      <li><para>aaa</para></li>
      <li><para>bbb</para></li>
    </ol>
  </dita>
  END

    $a->𝗱𝗶𝘁𝗮𝗢𝗯𝘃𝗶𝗼𝘂𝘀𝗖𝗵𝗮𝗻𝗴𝗲𝘀;

    ok -p $a eq <<END;
  <dita>
    <ol>
      <li>
        <p>aaa</p>
      </li>
      <li>
        <p>bbb</p>
      </li>
    </ol>
  </dita>
  END

ditaXrefs($)

Make obvious changes to all the xrefs found in a parse tree to make them more useful in Dita.

     Parameter  Description
  1  $x         Parse tree

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <body>
   <xref href="http://www.org">a</xref>
  </body>
  END

    $a->𝗱𝗶𝘁𝗮𝗫𝗿𝗲𝗳𝘀;

    ok -p $a eq <<END;
  <body>
    <p>
      <xref format="html" href="http://www.org" scope="external">a</xref>
    </p>
  </body>
  END
   }

ditaSampleConcept(%)

Sample concept

     Parameter  Description
  1  @options   Options for concept

Example:

  if (1) {
    ok Data::Edit::Xml::𝗱𝗶𝘁𝗮𝗦𝗮𝗺𝗽𝗹𝗲𝗖𝗼𝗻𝗰𝗲𝗽𝘁
     (title=>q(New Concept),
     )->prettyString eq <<END;
  <concept id="GUID-42c09175-dfa9-c02e-d747-2f5e89ea80fc">
    <title id="title">New Concept</title>
    <conbody/>
  </concept>
  END
   }

This is a static method and so should be invoked as:

  Data::Edit::Xml::ditaSampleConcept

ditaSampleTask(%)

Sample task

     Parameter  Description
  1  @options   Options for task

Example:

  if (1) {
    ok Data::Edit::Xml::𝗱𝗶𝘁𝗮𝗦𝗮𝗺𝗽𝗹𝗲𝗧𝗮𝘀𝗸
     (title=>q(New Task),
     )->prettyString eq <<END;
  <task id="GUID-2ac5c2a6-2475-d5d4-4ce6-d68fdf2102e3">
    <title id="title">New Task</title>
    <taskbody>
      <context/>
      <steps/>
      <result/>
    </taskbody>
  </task>
  END
   }

This is a static method and so should be invoked as:

  Data::Edit::Xml::ditaSampleTask

ditaSampleBookMap(%)

Sample bookmap

     Parameter  Description
  1  @options   Options for bookmap

Example:

  if (1) {
  ok nws(Data::Edit::Xml::𝗱𝗶𝘁𝗮𝗦𝗮𝗺𝗽𝗹𝗲𝗕𝗼𝗼𝗸𝗠𝗮𝗽
   (author=>q(mim),
    chapters=>Data::Edit::Xml::new(<<END),
  <a>
    <b>
      <c/>
    </b>
  </a>
  END
   )->prettyString) eq nws(<<END);
  <bookmap id="GUID-d20780be-2546-a22c-5208-f02472affc88">
    <booktitle>
      <mainbooktitle>Title unknown</mainbooktitle>
    </booktitle>
    <bookmeta>
      <shortdesc/>
      <author>mim</author>
      <source/>
      <category/>
      <prodinfo>
        <prodname product=""/>
        <vrmlist>
          <vrm version=""/>
        </vrmlist>
        <prognum/>
        <brand/>
      </prodinfo>
      <bookrights>
        <copyrfirst>
          <year/>
        </copyrfirst>
        <bookowner/>
      </bookrights>
    </bookmeta>
    <frontmatter>
      <notices/>
      <booklists>
        <toc/>
      </booklists>
      <preface/>
    </frontmatter>
    <a>
      <b>
        <c/>
      </b>
    </a>
    <appendices/>
    <reltable>
      <relheader>
        <relcolspec/>
        <relcolspec/>
      </relheader>
      <relrow>
        <relcell/>
        <relcell/>
      </relrow>
      <relrow>
        <relcell/>
        <relcell/>
      </relrow>
    </reltable>
  </bookmap>
  END
   }

This is a static method and so should be invoked as:

  Data::Edit::Xml::ditaSampleBookMap

ditaOrganization()

Set the dita organization field in the xml headers, set by default to OASIS.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <concept/>
  END

    Data::Edit::Xml::𝗱𝗶𝘁𝗮𝗢𝗿𝗴𝗮𝗻𝗶𝘇𝗮𝘁𝗶𝗼𝗻 = q(ACT);

    ok $a->prettyStringDitaHeaders eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

    ok -x $a eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END

ditaTopicHeaders($)

Add xml headers for the dita document type indicated by the specified parse tree

     Parameter  Description
  1  $node      Node in parse tree

Example:

    ok Data::Edit::Xml::new(q(<concept/>))->𝗱𝗶𝘁𝗮𝗧𝗼𝗽𝗶𝗰𝗛𝗲𝗮𝗱𝗲𝗿𝘀 eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd" []>
  END

ditaPrettyPrintWithHeaders($)

Add xml headers for the dita document type indicated by the specified parse tree to a pretty print of the parse tree.

     Parameter  Description
  1  $node      Node in parse tree

Example:

  if (1)
   {my $a = Data::Edit::Xml::new(q(<concept/>));
    ok $a->𝗱𝗶𝘁𝗮𝗣𝗿𝗲𝘁𝘁𝘆𝗣𝗿𝗶𝗻𝘁𝗪𝗶𝘁𝗵𝗛𝗲𝗮𝗱𝗲𝗿𝘀 eq <<END;
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE concept PUBLIC "-//ACT//DTD DITA Concept//EN" "concept.dtd" []>
  <concept/>
  END
   }

htmlHeadersToSections($)

Position sections just before html header tags so that subsequently the document can be divided into sections.

     Parameter  Description
  1  $node      Parse tree

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
  <h1>h1</h1>
    H1
  <h2>h2</h2>
    H2
  <h3>h3</h3>
    H3
  <h3>h3</h3>
    H3
  <h2>h2</h2>
    H2
  <h4>h4</h4>
    H4
  </x>
  END

  $x->𝗵𝘁𝗺𝗹𝗛𝗲𝗮𝗱𝗲𝗿𝘀𝗧𝗼𝗦𝗲𝗰𝘁𝗶𝗼𝗻𝘀;

    $x->divideDocumentIntoSections(sub

     {my ($topicref, $section) = @_;

      my $file = keys %file;

      $topicref->href = $file;

      $file{$file} = -p $section;

      $section->cut;

     });

    ok -p $x eq <<END;
  <x>
    <topicref href="0">
      <topicref href="1">
        <topicref href="2"/>
        <topicref href="3"/>
      </topicref>
      <topicref href="4">
        <topicref href="5"/>
      </topicref>
    </topicref>
  </x>
  END

    ok  nn(dump({map {$_=>nn($file{$_})} keys %file})) eq nn(dump(

     {"0" => "<section level=\"1\">N  <h1>h1</h1>NN  H1NN</section>N",

      "1" => "<section level=\"2\">N  <h2>h2</h2>NN  H2NN</section>N",

      "2" => "<section level=\"3\">N  <h3>h3</h3>NN  H3NN</section>N",

      "3" => "<section level=\"3\">N  <h3>h3</h3>NN  H3NN</section>N",

      "4" => "<section level=\"2\">N  <h2>h2</h2>NN  H2NN</section>N",

      "5" => "<section level=\"4\">N  <h4>h4</h4>NN  H4NN</section>N",

divideDocumentIntoSections($$)

Divide a parse tree into sections by moving non section tags into their corresponding section so that the section tags expand until they are contiguous. The sections are then cut out by applying the specified sub to each section tag in the parse tree. The specified sub will receive the containing topicref and the section to be cut out as parameters allowing a reference to the cut out section to be inserted into the topicref.

     Parameter  Description
  1  $node      Parse tree
  2  $cutSub    Cut out sub

Example:

   {my $x = Data::Edit::Xml::new(<<END);
  <x>
  <h1>h1</h1>
    H1
  <h2>h2</h2>
    H2
  <h3>h3</h3>
    H3
  <h3>h3</h3>
    H3
  <h2>h2</h2>
    H2
  <h4>h4</h4>
    H4
  </x>
  END

  $x->htmlHeadersToSections;

    $x->𝗱𝗶𝘃𝗶𝗱𝗲𝗗𝗼𝗰𝘂𝗺𝗲𝗻𝘁𝗜𝗻𝘁𝗼𝗦𝗲𝗰𝘁𝗶𝗼𝗻𝘀(sub

     {my ($topicref, $section) = @_;

      my $file = keys %file;

      $topicref->href = $file;

      $file{$file} = -p $section;

      $section->cut;

     });

    ok -p $x eq <<END;
  <x>
    <topicref href="0">
      <topicref href="1">
        <topicref href="2"/>
        <topicref href="3"/>
      </topicref>
      <topicref href="4">
        <topicref href="5"/>
      </topicref>
    </topicref>
  </x>
  END

    ok  nn(dump({map {$_=>nn($file{$_})} keys %file})) eq nn(dump(

     {"0" => "<section level=\"1\">N  <h1>h1</h1>NN  H1NN</section>N",

      "1" => "<section level=\"2\">N  <h2>h2</h2>NN  H2NN</section>N",

      "2" => "<section level=\"3\">N  <h3>h3</h3>NN  H3NN</section>N",

      "3" => "<section level=\"3\">N  <h3>h3</h3>NN  H3NN</section>N",

      "4" => "<section level=\"2\">N  <h2>h2</h2>NN  H2NN</section>N",

      "5" => "<section level=\"4\">N  <h4>h4</h4>NN  H4NN</section>N",

ditaParagraphToNote($$)

Convert all <p> nodes to <note> if the paragraph starts with 'Note:', optionally wrapping the content of the <note> with a <p>

     Parameter                     Description
  1  $node                         Parse tree
  2  $wrapNoteContentWithParagaph  Wrap the <note> content with a <p> if true

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <p> Note: see over for details.</p>
  </a>
  END

    $a->𝗱𝗶𝘁𝗮𝗣𝗮𝗿𝗮𝗴𝗿𝗮𝗽𝗵𝗧𝗼𝗡𝗼𝘁𝗲(1);

    ok -p $a eq <<END;
  <a>
    <note>
      <p>See over for details.</p>
    </note>
  </a>
  END

wordStyles($)

Extract style information from a parse tree representing a word document.

     Parameter  Description
  1  $x         Parse tree

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
   <text:list-style style:name="aa">
     <text:list-level-style-bullet text:level="2"/>
   </text:list-style>
  </a>
  END

    my $styles = $a->𝘄𝗼𝗿𝗱𝗦𝘁𝘆𝗹𝗲𝘀;

    is_deeply $styles, {bulletedList=>{aa=>{2=>1}}};

htmlTableToDita($)

Convert an html table to a Dita table.

     Parameter  Description
  1  $table     Html table node

Example:

   {my $a = Data::Edit::Xml::new(<<END);
   <table>
     <thead>
      <tr>
         <th>Month</th>
         <th>Savings</th>
         <th>Phone</th>
         <th>Comment</th>
      </tr>
     </thead>
     <tbody>
      <tr>
         <td>January</td>
         <td>100</td>
         <td>555-1212</td>
      </tr>
      <tr>
         <td>February</td>
         <td>80</td>
      </tr>
     </tbody>
  </table>
  END

    $a->𝗵𝘁𝗺𝗹𝗧𝗮𝗯𝗹𝗲𝗧𝗼𝗗𝗶𝘁𝗮;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="4">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <colspec colname="c3" colnum="3" colwidth="1*"/>
      <colspec colname="c4" colnum="4" colwidth="1*"/>
      <thead>
        <row>
          <entry>Month</entry>
          <entry>Savings</entry>
          <entry>Phone</entry>
          <entry>Comment</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>January</entry>
          <entry>100</entry>
          <entry nameend="c4" namest="c3">555-1212</entry>
        </row>
        <row>
          <entry>February</entry>
          <entry nameend="c4" namest="c2">80</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

Debug

Debugging methods

printAttributes($)

Print the attributes of a node.

     Parameter  Description
  1  $node      Node whose attributes are to be printed.

Example:

   {my $x = Data::Edit::Xml::new(my $s = <<END);
  <a no="1" word="first"/>
  END

    ok $x->𝗽𝗿𝗶𝗻𝘁𝗔𝘁𝘁𝗿𝗶𝗯𝘂𝘁𝗲𝘀 eq qq( no="1" word="first");

printNode($)

Print the tag and attributes of a node.

     Parameter  Description
  1  $node      Node to be printed.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c id="42" match="mm"/>
    </b>
    <d>
      <e/>
    </d>
  </a>
  END

    ok $c->𝗽𝗿𝗶𝗻𝘁𝗡𝗼𝗱𝗲 eq q(c id="42" match="mm");

goFish($@)

A debug version of go that returns additional information explaining any failure to reach the node identified by the path.

Returns ([reachable tag...], failing tag, [possible tag...]) where:

reachable tag

the path elements successfully traversed;

failing tag

the failing element;

possible tag

the possibilities at the point where the path failed if it failed else undef.

Parameters:

     Parameter  Description
  1  $node      Node
  2  @path      Search specification.

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c>
        <d/>
      </c>
      <c/>
    </b>
    <b/>
  </a>
  END

      my ($good, $fail, $possible) = $a->𝗴𝗼𝗙𝗶𝘀𝗵(qw(b c D));

      ok  $fail eq q(D);

      is_deeply $good,     [qw(b c)];

      is_deeply $possible, [q(d)];

Compression

Read and write files of compressed xml. These methods provide a compact, efficient way to store and retrieve parse trees to/from files.

writeCompressedFile($$)

Write the parse tree starting at $node as compressed xml to the specified $file. Use readCompressedFile to read the $file.

     Parameter  Description
  1  $node      Parse tree node
  2  $file      File to write to.

Example:

    my $a = Data::Edit::Xml::new(q(<a>).(q(<b>𝝱</b>)x1e3).q(</a>));

    my $file = $a->𝘄𝗿𝗶𝘁𝗲𝗖𝗼𝗺𝗽𝗿𝗲𝘀𝘀𝗲𝗱𝗙𝗶𝗹𝗲(q(zzz.xml.zip));

    my $A = readCompressedFile($file);

    ok $a->equals($A);

readCompressedFile($)

Read the specified $file containing compressed xml and return the root node. Use writeCompressedFile to write the $file.

     Parameter  Description
  1  $file      File to read.

Example:

    my $a = Data::Edit::Xml::new(q(<a>).(q(<b>𝝱</b>)x1e3).q(</a>));

    my $file = $a->writeCompressedFile(q(zzz.xml.zip));

    my $A = 𝗿𝗲𝗮𝗱𝗖𝗼𝗺𝗽𝗿𝗲𝘀𝘀𝗲𝗱𝗙𝗶𝗹𝗲($file);

    ok $a->equals($A);

This is a static method and so should be invoked as:

  Data::Edit::Xml::readCompressedFile

Autoload

Allow methods with constant parameters to be called as method_p1_p2...(variable parameters) whenever it is easier to type underscores than (qw()).

AUTOLOAD()

Allow methods with constant parameters to be called as method_p1_p2...(variable parameters) whenever it is easier to type underscores than (qw()).

Example:

   {my $a = Data::Edit::Xml::new(<<END);
  <a>
    <b>
      <c/>
    </b>
  </a>
  END

    my ($c, $b) = $a->byList;

    ok  $c->at_c_b_a;

    ok !$c->at_b;

    ok  -t $c->change_d_c_b eq q(d);

    ok !   $c->change_d_b;

  if (1)
   {my $a = Data::Edit::Xml::new(<<END);
  <a><b><c/><d/><e/><f/></b></a>
  END

    ok -t $a->first_b__first_c__next__next_e__next eq q(f);
    ok   !$a->first_b__first_c__next__next_f;
   }

Hash Definitions

Data::Edit::Xml Definition

Well known attributes useful in respect to xml that conforms to the Dita standard.

attributes - The attributes of the specified $node, see also: "Attributes". The frequently used attributes: class, id, href, outputclass can be accessed by an lvalue method as in: $node->id = 'c1'.

audience - Attribute audience for a node as an lvalue sub. Use audienceX() to return q() rather than undef.

class - Attribute class for a node as an lvalue sub. Use classX() to return q() rather than undef.

conditions - Conditional strings attached to a node, see "Conditions".

content - Content of command: the nodes immediately below the specified $node in the order in which they appeared in the source text, see also "Contents".

data - A hash added to the node for use by the programmer during transformations. The data in this hash will not be printed by any of the printed methods and so can be used to add data to the parse tree that will not be seen in any output xml produced from the parse tree.

depthProfileLast - The last known depth profile for this node as set by setDepthProfiles.

errorsFile - Error listing file. Use this parameter to explicitly set the name of the file that will be used to write any parse errors to. By default this file is named: zzzParseErrors/out.data.

forestNumbers - Index to node by forest number as set by numberForest.

guid - Attribute guid for a node as an lvalue sub. Use guidX() to return q() rather than undef.

href - Attribute href for a node as an lvalue sub. Use hrefX() to return q() rather than undef.

id - Attribute id for a node as an lvalue sub. Use idX() to return q() rather than undef.

indexes - Indexes to sub commands by tag in the order in which they appeared in the source text.

input - Source of the parse if this is the parser root node. Use this parameter to specify some input either as a string or as a file name for the parser to convert into a parse tree.

inputFile - Source file of the parse if this is the parser root node. Use this parameter to explicitly set the file to be parsed.

inputString - Source string of the parse if this is the parser root node. Use this parameter to explicitly set the string to be parsed.

labels - The labels attached to a node to provide addressability from other nodes, see: "Labels".

lang - Attribute lang for a node as an lvalue sub. Use langX() to return q() rather than undef.

lineNumbers - If true then save the line number.column number at which tag starts and ends on the xtrf attribute of each node.

navtitle - Attribute navtitle for a node as an lvalue sub. Use navtitleX() to return q() rather than undef.

number - Number of the specified $node, see findByNumber.

numbering - Last number used to number a node in this parse tree.

numbers - Nodes by number.

otherprops - Attribute otherprops for a node as an lvalue sub. Use otherpropsX() to return q() rather than undef.

outputclass - Attribute outputclass for a node as an lvalue sub. Use outputclassX() to return q() rather than undef.

parent - Parent node of the specified $node or undef if the parser root node. See also "Traversal" and "Navigation". Consider as read only.

parser - Parser details: the root node of a tree is the parser node for that tree. Consider as read only.

props - Attribute props for a node as an lvalue sub. Use propsX() to return q() rather than undef.

representationLast - The last representation set for this node by one of: setRepresentationAsTagsAndText.

style - Attribute style for a node as an lvalue sub. Use styleX() to return q() rather than undef.

tag - Tag name for the specified $node, see also "Traversal" and "Navigation". Consider as read only.

text - Text of the specified $node but only if it is a text node, i.e. the tag is cdata() <=> "isText" is true.

type - Attribute type for a node as an lvalue sub. Use typeX() to return q() rather than undef.

xtrc - Attribute xtrc for a node as an lvalue sub. Use classX() to return q() rather than undef.

xtrf - Attribute xtrf for a node as an lvalue sub. Use classX() to return q() rather than undef.

Data::Edit::Xml::Table::Statistics Definition

Statistics about a table

colSpec - Number of colspec entries

colsAttribute - Column attribute

maxBody - Maximum number of entries in a body row regardless of padding rows

maxBodyMinusPadding - Maximum number of entries in a body row after an padding entries have been removed

maxHead - Maximum number of entries in a head row regardless of padding rows

maxHeadMinusPadding - Maximum number of entries in a head row after an padding entries have been removed

minBody - Maximum number of entries in a body row regardless of padding rows

minHead - Maximum number of entries in a head row regardless of padding rows

Private Methods

tree($$)

Build a tree representation of the parsed XML which can be easily traversed to look for things.

     Parameter  Description
  1  $parent    The parent node
  2  $parse     The remaining parse

addLineNumbers($)

Add line numbers to the source

     Parameter  Description
  1  $string    Source string

disconnectLeafNode($)

Remove a leaf node from the parse tree and make it into its own parse tree.

     Parameter  Description
  1  $node      Leaf node to disconnect.

reindexNode($)

Index the children of a node so that we can access them by tag and number.

     Parameter  Description
  1  $node      Node to index.

indexNode($)

Merge multiple text segments and set parent and parser after changes to a node

     Parameter  Description
  1  $node      Node to index.

normalizeWhiteSpace($)

Normalize white space, remove comments DOCTYPE and xml processors from a string

     Parameter  Description
  1  $string    String to normalize

This is a static method and so should be invoked as:

  Data::Edit::Xml::normalizeWhiteSpace

prettyStringEnd($)

Return a readable string representing a node of a parse tree and all the nodes below it as a here document

     Parameter  Description
  1  $node      Start node

byX2($$@)

Post-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call
  3  @context   Accumulated context.

byX22($$@)

Post-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call
  3  @context   Accumulated context.

downX2($$@)

Pre-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call
  3  @context   Accumulated context.

downX22($$@)

Pre-order traversal down through a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node. The sub is passed references to the current node and all of its ancestors. The value of the current node is also made available via $_.

     Parameter  Description
  1  $node      Starting node
  2  $sub       Sub to call for each sub node
  3  @context   Accumulated context.

atPositionMatch($$)

Confirm that a string matches a match expression.

     Parameter  Description
  1  $tag       Starting node
  2  $match     Ancestry.

numberNode($)

Ensure that the specified $node has a number.

     Parameter  Description
  1  $node      Node

createRequiredCleanUp($$)

Create a required clean up node

     Parameter  Description
  1  $node      Node
  2  $text      Clean up message

ditaMergeListsOnce($)

Merge the specified $node with the preceding or following list or steps or substeps if possible and return the specified $node regardless.

     Parameter  Description
  1  $node      Node

ditaAddPadEntriesToTGroupRows($$)

Adding padding entries to a tgroup to make sure every row has the same number of entries

     Parameter  Description
  1  $tgroup    TGroup node
  2  $nEntries  Number of entries

Example:

  if (1) {
    my $a = Data::Edit::Xml::new(<<END);
  <table>
    <tgroup cols="1">
      <colspec/>
      <thead>
        <row>
          <entry>aaaa</entry>
        </row>
        <row>
          <entry>bbbb</entry>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
        </row>
        <row>
          <entry>dddd</entry>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    my $g = $a->go_tgroup;

    $g->𝗱𝗶𝘁𝗮𝗔𝗱𝗱𝗣𝗮𝗱𝗘𝗻𝘁𝗿𝗶𝗲𝘀𝗧𝗼𝗧𝗚𝗿𝗼𝘂𝗽𝗥𝗼𝘄𝘀(2);

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 1,
    colSpec => 1,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $g->fixTGroup;

    ok -p $a eq <<END;
  <table>
    <tgroup cols="2">
      <colspec colname="c1" colnum="1" colwidth="1*"/>
      <colspec colname="c2" colnum="2" colwidth="1*"/>
      <thead>
        <row>
          <entry>aaaa</entry>
          <entry/>
        </row>
        <row>
          <entry>bbbb</entry>
          <entry/>
        </row>
      </thead>
      <tbody>
        <row>
          <entry>cccc</entry>
          <entry/>
        </row>
        <row>
          <entry>dddd</entry>
          <entry/>
        </row>
      </tbody>
    </tgroup>
  </table>
  END

    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

    $a->fixTable;
    is_deeply $g->ditaTGroupStatistics,
  bless({
    colsAttribute => 2,
    colSpec => 2,
    maxBody => 2,
    maxBodyMinusPadding => 2,
    maxHead => 2,
    maxHeadMinusPadding => 2,
    minBody => 2,
    minHead => 2,
  }, "Data::Edit::Xml::Table::Statistics");

   }

topicTypeAndBody($)

Topic type and corresponding body.

     Parameter  Description
  1  $type      Type from qw(bookmap concept reference task)

getSectionHeadingLevel($)

Get the heading level from a section tag.

     Parameter  Description
  1  $o         Node

printAttributesReplacingIdsWithLabels($)

Print the attributes of a node replacing the id with the labels.

     Parameter  Description
  1  $node      Node whose attributes are to be printed.

printAttributesExtendingIdsWithLabels($)

Print the attributes of a node extending the id with the labels.

     Parameter  Description
  1  $node      Node whose attributes are to be printed.

checkParentage($)

Check the parent pointers are correct in a parse tree.

     Parameter  Description
  1  $x         Parse tree.

checkParser($)

Check that every node has a parser.

     Parameter  Description
  1  $x         Parse tree.

nn($)

Replace new lines in a string with N to make testing easier.

     Parameter  Description
  1  $s         String.

Synonyms

firstLeaf is a synonym for downWhileFirst - Move down from the specified $node as long as each lower node is a first node.

lastLeaf is a synonym for downWhileLast - Move down from the specified $node as long as each lower node is a last node.

mnt is a synonym for matchesNextTags - Return the specified b<$node> if the siblings following the specified $node match the specified <@tags> else return undef.

mpt is a synonym for matchesPrevTags - Return the specified b<$node> if the siblings prior to the specified $node match the specified <@tags> else return undef.

oat is a synonym for overAllTags - Return the specified b<$node> if all of it's child nodes match the specified <@tags> else return undef.

oft is a synonym for overFirstTags - Return the specified b<$node> if the first of it's child nodes match the specified <@tags> else return undef.

olt is a synonym for overLastTags - Return the specified b<$node> if the last of it's child nodes match the specified <@tags> else return undef.

Index

1 above - Return the first node if the first node is above the second node optionally checking that the first node is in the specified context otherwise return undef

2 abovePath - Return the nodes along the path from the first node down to the second node when the first node is above the second node else return ().

3 addConditions - Add conditions to a node and return the node.

4 addFirst - Add a new node first below the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

5 addFirstAsText - Add a new text node first below the specified $node and return the new node unless a text node already exists there and starts with the same text in which case return the existing $node.

6 addLabels - Add the named labels to the specified $node and return the number of labels added.

7 addLast - Add a new node last below the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

8 addLastAsText - Add a new text node last below the specified $node and return the new node unless a text node already exists there and ends with the same text in which case return the existing $node.

9 addLineNumbers - Add line numbers to the source

10 addNext - Add a new node next to the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

11 addNextAsText - Add a new text node after the specified $node and return the new node unless a text node already exists there and starts with the same text in which case return the existing $node.

12 addPrev - Add a new node before the specified $node and return the new node unless a node with that tag already exists in which case return the existing $node.

13 addPrevAsText - Add a new text node before the specified $node and return the new node unless a text node already exists there and ends with the same text in which case return the existing $node.

14 addSingleChild - Wrap the content of a specified $node in a new node with the specified $tag and optional %attribute unless the content is already wrapped in a single child with the specified $tag.

15 addWrapWith - Wrap the specified $node with the specified tag if the node is not already wrapped with such a tag and return the new node unless a node with that tag already exists in which case return the existing $node.

16 adjacent - Return the first node if it is adjacent to the second node else undef.

17 after - Return the first node if it occurs after the second node in the parse tree optionally checking that the first node is in the specified context or else undef if the node is above, below or before the target.

18 allConditions - Return the node if it has all of the specified conditions, else return undef

19 an - Return the next node if the specified $node has the specified tag and the next node is in the specified context.

20 ancestry - Return a list containing: (the specified $node, its parent, its parent's parent etc.

21 anyCondition - Return the node if it has any of the specified conditions, else return undef

22 ap - Return the previous node if the specified $node has the specified tag and the previous node is in the specified context.

23 apn - Return (previous node, next node) if the previous and current nodes have the specified tags and the next node is in the specified context else return ().

24 approxLocation - Return the line number.

25 at - Confirm that the specified $node has the specified ancestry and return the specified $node if it does else undef.

26 atOrBelow - Confirm that the node or one of its ancestors has the specified context as recognized by at and return the first node that matches the context or undef if none do.

27 atPositionMatch - Confirm that a string matches a match expression.

28 attr - Return the value of an attribute of the current node as an lvalue sub.

29 attrCount - Return the number of attributes in the specified $node, optionally ignoring the specified names from the count.

30 attrs - Return the values of the specified attributes of the current node as a list

31 attrValueAt - Return the specified $node if it has the specified $attribute with the specified $value and the optional specified ancestry else return undef.

32 attrX - Return the value of the specified $attribute of the specified $node or q() if the $node does not have such an attribute.

33 AUTOLOAD - Allow methods with constant parameters to be called as method_p1_p2.

34 before - Return the first node if it occurs before the second node in the parse tree optionally checking that the first node is in the specified context or else undef if the node is above, below or before the target.

35 below - Return the first node if the first node is below the second node optionally checking that the first node is in the specified context otherwise return undef

36 belowPath - Return the nodes along the path from the first node up to the second node when the first node is below the second node else return ().

37 bitsNodeTextBlank - Return a bit string that shows if there are any non text nodes, text nodes or blank text nodes under a node.

38 breakIn - Concatenate the nodes following and preceding the start node, unwrapping nodes whose tag matches the start node and return the start node.

39 breakInBackwards - Concatenate the nodes preceding the start node, unwrapping nodes whose tag matches the start node and return the start node in the manner of breakIn.

40 breakInForwards - Concatenate the nodes following the start node, unwrapping nodes whose tag matches the start node and return the start node in the manner of breakIn.

41 breakOut - Lift child nodes with the specified tags under the specified parent node splitting the parent node into clones and return the cut out original node.

42 by - Post-order traversal of a parse tree or sub tree calling the specified sub at each node and returning the specified starting node.

43 byList - Return a list of all the nodes at and below a specified $node in post-order or the empty list if the $node is not in the optional context.

44 byReverse - Reverse post-order traversal of a parse tree or sub tree calling the specified sub at each node and returning the specified starting $node.

45 byReverseList - Return a list of all the nodes at and below a specified $node in reverse preorder or the empty list if the specified $node is not in the optional context.

46 byReverseX - Reverse post-order traversal of a parse tree or sub tree below the specified $node calling the specified sub within eval{} at each node and returning the specified starting $node.

47 byX - Post-order traversal of a parse tree calling the specified sub at each node as long as this sub does not die.

48 byX2 - Post-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node.

49 byX22 - Post-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node.

50 c - Return an array of all the nodes with the specified tag below the specified $node.

51 cdata - The name of the tag to be used to represent text - this tag must not also be used as a command tag otherwise the parser will confess.

52 change - Change the name of the specified $node, optionally confirming that the $node is in a specified context and return the $node.

53 changeAttr - Change the name of an attribute in the specified $node unless it has already been set and return the node.

54 changeAttributeValue - Apply a sub to the value of an attribute of the specified $node.

55 changeAttrValue - Change the name and value of an attribute in the specified $node unless it has already been set and return the node.

56 changeReasonCommentSelectionSpecification - Provide a specification to select change reason comments to be inserted as text into a parse tree.

57 changeText - If the specified $node is a text node in the specified context then the specified sub is passed the text of the node in $_, any changes to which are recorded in the text of the $node.

58 checkParentage - Check the parent pointers are correct in a parse tree.

59 checkParser - Check that every node has a parser.

60 childOf - Returns the specified $child node if it is a child of the specified $parent node and the $child node is in the specified optional context.

61 clone - Return a clone of the parse tree optionally checking that the starting node is in a specified context: the parse tree is cloned without converting it to string and reparsing it so this method will not renew any nodes added as text.

62 closestLocation - Return the nearest node with line number.

63 commonAdjacentAncestors - Given two nodes, find a pair of adjacent ancestral siblings if such a pair exists else return ().

64 commonAncestor - Find the most recent common ancestor of the specified nodes or undef if there is no common ancestor.

65 concatenate - Concatenate two successive nodes and return the target node.

66 concatenateSiblings - Concatenate preceding and following nodes as long as they have the same tag as the specified $node and return the specified $node.

67 condition - Return the node if it has the specified condition and is in the optional context, else return undef

68 containsSingleText - Return the single text element below the specified $node else return undef.

69 contentAfter - Return a list of all the sibling nodes following the specified $node or an empty list if the specified $node is last or not in the optional context.

70 contentAfterAsTags - Return a string containing the tags of all the sibling nodes following the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context.

71 contentAfterAsTags2 - Return a string containing the tags of all the sibling nodes following the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context.

72 contentAsTags - Return a string containing the tags of all the child nodes of the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context.

73 contentAsTags2 - Return a string containing the tags of all the child nodes of the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context.

74 contentBefore - Return a list of all the sibling nodes preceding the specified $node (in the normal sibling order) or an empty list if the specified $node is last or not in the optional context.

75 contentBeforeAsTags - Return a string containing the tags of all the sibling nodes preceding the specified $node separated by single spaces or the empty string if the node is empty or undef if the node does not match the optional context.

76 contentBeforeAsTags2 - Return a string containing the tags of all the sibling nodes preceding the specified $node separated by two spaces with a single space preceding the first tag and a single space following the last tag or the empty string if the node is empty or undef if the node does not match the optional context.

77 contents - Return a list of all the nodes contained by the specified $node or an empty list if the node is empty or not in the optional context.

78 context - Return a string containing the tag of the starting node and the tags of all its ancestors separated by single spaces.

79 copyAttrs - Copy all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, overwriting any existing attributes in the target node and return the source node.

80 copyLabels - Copy all the labels from the source node to the target node and return the source node.

81 copyLabelsAndIdsInTree - Copy all the labels and ids in the source parse tree to the matching nodes in the target parse tree.

82 copyNewAttrs - Copy all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, without overwriting any existing attributes in the target node and return the source node.

83 count - Return the count of the number of instances of the specified tags under the specified $node, either by tag in array context or in total in scalar context.

84 countAttrNames - Return a reference to a hash showing the number of instances of each attribute on and below the specified $node.

85 countAttrNamesOnTagExcluding - Count the number of attributes owned by the specified $node that are not in the specified list.

86 countAttrValues - Return a reference to a hash showing the number of instances of each attribute value on and below the specified $node.

87 countLabels - Return the count of the number of labels at a node.

88 countOutputClasses - Count instances of outputclass attributes

89 countTagNames - Return a reference to a hash showing the number of instances of each tag on and below the specified $node.

90 countTags - Count the number of tags in a parse tree.

91 crc - Insert a comment consisting of a code and an optional reason as text into the parse tree to indicate the location of changes to the parse tree.

92 createGuidId - Create an id for the specified $node from the md5Sum of its content moving any existing id to the labels associated with the $node and return the existing $node.

93 createPatch - Create a patch that moves the source parse tree to the target parse tree node as long as they have the same tag and id structure with each id being unique.

94 createRequiredCleanUp - Create a required clean up node

95 cut - Cut out the specified $node so that it can be reinserted else where in the parse tree.

96 Data::Edit::Xml::Patch::install - Replay a patch created by createPatch against a parse tree that has the same tag and id structure with each id being unique.

97 deleteAttr - Delete the named attribute in the specified $node, optionally check its value first, return the node regardless.

98 deleteAttrs - Delete the specified attributes of the specified $node without checking their values and return the node.

99 deleteAttrsInTree - Delete the specified attributes of the specified $node and all the nodes under it and return the specified $node.

100 deleteAttrValueAtInTree - Delete all instances of the specified $attribute with the specified $value in the specified @context in the specified $tree and return the modified $tree.

101 deleteConditions - Delete conditions applied to a node and return the node.

102 deleteContent - Delete the content of the specified $node.

103 deleteLabels - Delete the specified labels in the specified $node or all labels if no labels have are specified and return that node.

104 depth - Returns the depth of the specified $node, the depth of a root node is zero.

105 depthProfile - Returns the depth profile of the tree rooted at the specified $node.

106 diff - Return () if the dense string representations of the two nodes are equal, else up to the first N (default 16) characters of the common prefix before the point of divergence and the remainder of the string representation of each node from the point of divergence.

107 disconnectLeafNode - Remove a leaf node from the parse tree and make it into its own parse tree.

108 disordered - Return the first node that is out of the specified order when performing a pre-ordered traversal of the parse tree.

109 ditaAddColSpecToTGroup - Add the specified $number of column specification to a specified $tgroup which does not have any already.

110 ditaAddPadEntriesToTGroupRows - Adding padding entries to a tgroup to make sure every row has the same number of entries

111 ditaFixTGroupColSpec - Fix the colspec attribute and colspec nodes of the specified $tgroup.

112 ditaListToChoices - Change the specified $list to choices.

113 ditaListToSteps - Change the specified $node to steps and its contents to cmd\step optionally only in the specified context.

114 ditaListToStepsUnordered - Change the specified $node to steps-unordered and its contents to cmd\step optionally only in the specified context.

115 ditaListToSubSteps - Change the specified $node to substeps and its contents to cmd\step optionally only in the specified context.

116 ditaListToTable - Convert a list to a table in situ - as designed by MiM.

117 ditaMaximumNumberOfEntriesInATGroupRow - Return the maximum number of entries in the rows of the specified $table or undef if not a table.

118 ditaMergeLists - Merge the specified $node with the preceding or following list or steps or substeps if possible and return the specified $node regardless.

119 ditaMergeListsOnce - Merge the specified $node with the preceding or following list or steps or substeps if possible and return the specified $node regardless.

120 ditaObviousChanges - Make obvious changes to a parse tree to make it look more like Dita.

121 ditaOrganization - Set the dita organization field in the xml headers, set by default to OASIS.

122 ditaParagraphToNote - Convert all <p> nodes to <note> if the paragraph starts with 'Note:', optionally wrapping the content of the <note> with a <p>

123 ditaPrettyPrintWithHeaders - Add xml headers for the dita document type indicated by the specified parse tree to a pretty print of the parse tree.

124 ditaRemoveTGroupTrailingEmptyEntries - Remove empty trailing entry

125 ditaSampleBookMap - Sample bookmap

126 ditaSampleConcept - Sample concept

127 ditaSampleTask - Sample task

128 ditaStepsToChoices - Change the specified $node to choices.

129 ditaStepsToList - Change the specified $node to a node with name $tag or to ol if $tag is not supplied and its cmd\step content to li to create a list optionally only in the specified context.

130 ditaTGroupStatistics - Return statistics about the rows in a given table

131 ditaTopicHeaders - Add xml headers for the dita document type indicated by the specified parse tree

132 ditaXrefs - Make obvious changes to all the xrefs found in a parse tree to make them more useful in Dita.

133 divideDocumentIntoSections - Divide a parse tree into sections by moving non section tags into their corresponding section so that the section tags expand until they are contiguous.

134 down - Pre-order traversal down through a parse tree or sub tree calling the specified sub at each node and returning the specified starting node.

135 downList - Return a list of all the nodes at and below a specified $node in pre-order or the empty list if the $node is not in the optional context.

136 downReverse - Reverse pre-order traversal down through a parse tree or sub tree calling the specified sub at each node and returning the specified starting node.

137 downReverseList - Return a list of all the nodes at and below a specified $node in reverse pre-order or the empty list if the $node is not in the optional context.

138 downReverseX - Reverse pre-order traversal down through a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node.

139 downWhileFirst - Move down from the specified $node as long as each lower node is a first node.

140 downWhileHasSingleChild - Move down from the specified $node as long as it has a single child else return undef.

141 downWhileLast - Move down from the specified $node as long as each lower node is a last node.

142 downX - Pre-order traversal of a parse tree calling the specified sub at each node as long as this sub does not die.

143 downX2 - Pre-order traversal of a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node.

144 downX22 - Pre-order traversal down through a parse tree or sub tree calling the specified sub within eval{} at each node and returning the specified starting node.

145 equals - Return the first node if the two parse trees have identical representations via string, else undef.

146 equalsIgnoringAttributes - Return the first node if the two parse trees have identical representations via string if the specified attributes are ignored, else undef.

147 expandIncludes - Expand the includes mentioned in a parse tree: any tag that ends in include is assumed to be an include directive.

148 findByForestNumber - Find the node with the specified forest number as made visible on the id attribute by prettyStringNumbered in the parse tree containing the specified $node and return the found node or undef if no such node exists.

149 findById - Find a node in the parse tree under the specified $node with the specified $id.

150 findByNumber - Find the node with the specified number as made visible by prettyStringNumbered in the parse tree containing the specified $node and return the found node or undef if no such node exists.

151 findByNumbers - Find the nodes with the specified numbers as made visible by prettyStringNumbered in the parse tree containing the specified $node and return the found nodes in a list with undef for nodes that do not exist.

152 findMatchingSubTrees - Find nodes in the parse tree whose sub tree matches the specified $subTree excluding any of the specified $attributes.

153 first - Return the first node below the specified $node optionally checking the first node's context.

154 firstBy - Return a list of the first instance of each specified tag encountered in a post-order traversal from the specified $node or a hash of all first instances if no tags are specified.

155 firstContextOf - Return the first node encountered in the specified context in a depth first post-order traversal of the parse tree.

156 firstDown - Return a list of the first instance of each specified tag encountered in a pre-order traversal from the specified $node or a hash of all first instances if no tags are specified.

157 firstIn - Return the first child node matching one of the named tags under the specified parent node.

158 firstInIndex - Return the specified $node if it is first in its index and optionally at the specified context else undef

159 firstn - Return the $n'th first node below the specified $node optionally checking its context or undef if there is no such node.

160 firstNot - Return the first child node that does not match any of the named @tags under the specified parent $node.

161 firstOf - Return an array of the nodes that are continuously first under their specified parent node and that match the specified list of tags.

162 firstSibling - Return the first sibling of the specified $node in the optional context else undef

163 firstText - Return the first node under the specified $node if it is in the optional and it is a text node otherwise undef.

164 firstTextMatches - Return the first node under the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context.

165 firstUntil - Go first from the specified $node and continue deeper firstly until a first child node matches the specified @context or return undef if there is no such node.

166 firstUntilText - Go first from the specified $node and continue deeper firstly until a text node is encountered whose parent matches the specified @context or return undef if there is no such node.

167 firstWhile - Go first from the specified $node and continue deeper firstly as long as each first child node matches one of the specified @tags.

168 fixTable - Fix the specified $table so that each row has the same number of entries with this number reflected in the tgroup.

169 fixTGroup - Fix the specified $tgroup so that each row has the same number of entries with this number reflected in the tgroup.

170 forestNumberTrees - Number the ids of the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source.

171 formatOxygenMessage - Write an error message in Oxygen format

172 from - Return a list consisting of the specified node and its following siblings optionally including only those nodes that match one of the tags in the specified list.

173 fromTo - Return a list of the nodes between the specified start and end nodes optionally including only those nodes that match one of the tags in the specified list.

174 getAttrs - Return a sorted list of all the attributes on the specified $node.

175 getLabels - Return the names of all the labels set on a node.

176 getSectionHeadingLevel - Get the heading level from a section tag.

177 giveEveryIdAGuid - Give a guid to every node in the specified $tree that has an id attribute, saving any existing id attribute as a label, and return the count of the number of such replacements made.

178 go - Return the node reached from the specified $node via the specified path: (index position?)* where index is the tag of the next node to be chosen and position is the optional zero based position within the index of those tags under the current node.

179 goFish - A debug version of go that returns additional information explaining any failure to reach the node identified by the path.

180 hasSingleChild - Return the only child of the specified $node if the child is the only node under its parent ignoring any surrounding blank text and has the optional specified context, else return undef.

181 hasSingleChildToDepth - Return the specified $node if it has single children to at least the specified depth else return undef.

182 height - Returns the height of the tree rooted at the specified $node.

183 howFar - Return how far the first node is from the second node along a path through their common ancestor.

184 howFarAbove - Return how far the first node is above the second node is or 0 if the first node is not strictly above the second node.

185 howFarBelow - Return how far the first node is below the second node is or 0 if the first node is not strictly below the second node.

186 howFirst - Return the depth to which the specified $node is first else 0.

187 howLast - Return the depth to which the specified $node is last else 0.

188 howOnlyChild - Return the depth to which the specified $node is an only child else 0.

189 htmlHeadersToSections - Position sections just before html header tags so that subsequently the document can be divided into sections.

190 htmlTableToDita - Convert an html table to a Dita table.

191 index - Return the index of the specified $node in its parent index.

192 indexIds - Return a map of the ids at and below the specified $node.

193 indexNode - Merge multiple text segments and set parent and parser after changes to a node

194 invert - Swap a parent and child node where the child is the only child of the parent and return the parent.

195 invertFirst - Swap a parent and child node where the child is the first child of the parent by placing the parent last in the child.

196 invertLast - Swap a parent and child node where the child is the last child of the parent by placing the parent first in the child.

197 isAllBlankText - Return the specified $node if the specified $node, optionally in the specified context, does not contain anything or if it does contain something it is all white space else return undef.

198 isBlankText - Return the specified $node if the specified $node is a text node, optionally in the specified context, and contains nothing other than white space else return undef.

199 isEmpty - Confirm that the specified $node is empty, that is: the specified $node has no content, not even a blank string of text.

200 isFirst - Return the specified $node if it is first under its parent and optionally has the specified context, else return undef

201 isFirstText - Return the specified $node if the specified $node is a text node, the first node under its parent and that the parent is optionally in the specified context, else return undef.

202 isFirstToDepth - Return the specified $node if it is first to the specified depth else return undef

203 isLast - Return the specified $node if it is last under its parent and optionally has the specified context, else return undef

204 isLastText - Return the specified $node if the specified $node is a text node, the last node under its parent and that the parent is optionally in the specified context, else return undef.

205 isLastToDepth - Return the specified $node if it is last to the specified depth else return undef

206 isOnlyChild - Return the specified $node if it is the only node under its parent ignoring any surrounding blank text.

207 isOnlyChildBlankText - Return the specified $node if it is a blank text node and an only child else return undef.

208 isOnlyChildText - Return the specified $node if it is a text node and it is an only child else return undef.

209 isOnlyChildToDepth - Return the specified $node if it and its ancestors are only children to the specified depth else return undef.

210 isText - Return the specified $node if the specified $node is a text node, optionally in the specified context, else return undef.

211 labelsInTree - Return a hash of all the labels in a tree

212 last - Return the last node below the specified $node optionally checking the last node's context.

213 lastBy - Return a list of the last instance of each specified tag encountered in a post-order traversal from the specified $node or a hash of all last instances if no tags are specified.

214 lastContextOf - Return the last node encountered in the specified context in a depth first reverse pre-order traversal of the parse tree.

215 lastDown - Return a list of the last instance of each specified tag encountered in a pre-order traversal from the specified $node or a hash of all last instances if no tags are specified.

216 lastIn - Return the last child node matching one of the named tags under the specified parent node.

217 lastInIndex - Return the specified $node if it is last in its index and optionally at the specified context else undef

218 lastn - Return the $n'th last node below the specified $node optionally checking its context or undef if there is no such node.

219 lastNot - Return the last child node that does not match any of the named @tags under the specified parent $node.

220 lastOf - Return an array of the nodes that are continuously last under their specified parent node and that match the specified list of tags.

221 lastSibling - Return the last sibling of the specified $node in the optional context else undef

222 lastText - Return the last node under the specified $node if it is in the optional and it is a text node otherwise undef.

223 lastTextMatches - Return the last node under the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context.

224 lastUntil - Go last from the specified $node and continue deeper lastly until a last child node matches the specified @context or return undef if there is no such node.

225 lastUntilText - Go last from the specified $node and continue deeper lastly until a last child text node matches the specified @context or return undef if there is no such node.

226 lastWhile - Go last from the specified $node and continue deeper lastly as long as each last child node matches one of the specified @tags.

227 lineLocation - Return the line number.

228 listConditions - Return a list of conditions applied to a node.

229 location - Return the line number.

230 matchAfter - Confirm that the string representing the tags following the specified $node matches a regular expression where each pair of tags is separated by a single space.

231 matchAfter2 - Confirm that the string representing the tags following the specified $node matches a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space.

232 matchBefore - Confirm that the string representing the tags preceding the specified $node matches a regular expression where each pair of tags is separated by a single space.

233 matchBefore2 - Confirm that the string representing the tags preceding the specified $node matches a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space.

234 matchesNextTags - Return the specified b<$node> if the siblings following the specified $node match the specified <@tags> else return undef.

235 matchesNode - Return the $first node if it matches the $second node's tag and the specified @attributes else return undef.

236 matchesPrevTags - Return the specified b<$node> if the siblings prior to the specified $node match the specified <@tags> else return undef.

237 matchesSubTree - Return the $first node if it matches the $second node and the nodes under the first node match the corresponding nodes under the second node, else return undef.

238 matchesText - Returns an array of regular expression matches in the text of the specified $node if it is text node and it matches the specified regular expression and optionally has the specified context otherwise returns an empty array.

239 matchNodesByRepresentation - Creates a hash of arrays of nodes that have the same representation in the specified $tree.

240 matchTree - Return a list of nodes that match the specified tree of match expressions, else () if one or more match expressions fail to match nodes in the tree below the specified start node.

241 mergeDuplicateChildWithParent - Merge a parent node with its only child if their tags are the same and their attributes do not collide other than possibly the id in which case the parent id is used.

242 mergeLikeElements - Merge two of the same elements into one, retaining the order of any children.

243 mergeLikeNext - Merge a $node in an optional context with the next node if the two have the same tag by placing the next node first in the current $node and unwrapping the next node.

244 mergeLikePrev - Merge a $node in an optional context with the previous node if the two have the same tag by placing the previous node first in the current $node and unwrapping the previous node.

245 moveAttrs - Move all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to move is supplied, overwriting any existing attributes in the target node and return the source node.

246 moveEndAfter - Move the end of a $node to just after the specified $target node assuming that the $target node is either a subsequent sibling or a child of $node.

247 moveEndBefore - Move the end of a $node to just before the specified $target node assuming that the $target node is either a subsequent sibling or a child of $node.

248 moveEndLast - Move the end of a $node to contain all of its following siblings as children.

249 moveLabels - Move all the labels from the source node to the target node and return the source node.

250 moveNewAttrs - Move all the attributes of the source node to the target node, or, just the named attributes if the optional list of attributes to copy is supplied, without overwriting any existing attributes in the target node and return the source node.

251 moveStartAfter - Move the start end of a $node to just after the specified $target node assuming that the $target node is either a preceding sibling or a child of $node.

252 moveStartBefore - Move the start of a $node to just before the specified $target node assuming that the $target node is either a preceding sibling or a child of $node.

253 moveStartFirst - Move the start of a $node to contain all of its preceding siblings as children.

254 new - Create a new parse tree - call this method statically as in Data::Edit::Xml::new(file or string) to parse a file or string or with no parameters and then use "input", "inputFile", "inputString", "errorFile" to provide specific parameters for the parse, then call "parse" to perform the parse and return the parse tree.

255 newTag - Create a new non text node.

256 newText - Create a new text node.

257 newTree - Create a new tree.

258 next - Return the node next to the specified $node, optionally checking the next node's context.

259 nextIn - Return the nearest sibling after the specified $node that matches one of the named tags or undef if there is no such sibling node.

260 nextn - Return the $n'th next node after the specified $node optionally checking its context or undef if there is no such node.

261 nextOn - Step forwards as far as possible from the specified $node while remaining on nodes with the specified tags.

262 nextText - Return the node after the specified $node if it is in the optional and it is a text node otherwise undef.

263 nextTextMatches - Return the next node to the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context.

264 nextUntil - Go to the next sibling of the specified $node and continue forwards until the tag of a sibling node matches one of the specified @tags.

265 nextWhile - Go to the next sibling of the specified $node and continue forwards while the tag of each sibling node matches one of the specified @tags.

266 nn - Replace new lines in a string with N to make testing easier.

267 normalizeWhiteSpace - Normalize white space, remove comments DOCTYPE and xml processors from a string

268 not - Return the specified $node if it does not match any of the specified tags, else undef

269 numberNode - Ensure that the specified $node has a number.

270 numberTree - Number the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source.

271 numberTreesJustIds - Number the ids of the nodes in a parse tree in pre-order so they are numbered in the same sequence that they appear in the source.

272 opAt - <= : Check that a node is in the context specified by the referenced array of words.

273 opAttr - % : Get the value of an attribute of the specified $node.

274 opBy - x= : Traverse a parse tree in post-order.

275 opContents - @{} : nodes immediately below a node.

276 opCut - -- : Cut out a node.

277 opGo - >= : Search for a node via a specification provided as a reference to an array of words each number.

278 opNew - ** : create a new node from the text on the right hand side: if the text contains a non word character \W the node will be create as text, else it will be created as a tag

279 opPutFirst - >> : put a node or string first under a node and return the new node.

280 opPutFirstAssign - >>= : put a node or string first under a node.

281 opPutLast - << : put a node or string last under a node and return the new node.

282 opPutLastAssign - <<= : put a node or string last under a node.

283 opPutNext - > + : put a node or string after the specified $node and return the new node.

284 opPutNextAssign - += : put a node or string after the specified $node.

285 opPutPrev - < - : put a node or string before the specified $node and return the new node.

286 opPutPrevAssign - -= : put a node or string before the specified $node,

287 opString - -B: bitsNodeTextBlank

-b: isAllBlankText

-c: context

-e: prettyStringEnd

-f: first node

-g: pathString

-l: last node

-M: number

-o: contentAsTags

-p: prettyString

-s: string

-S : stringNode

-T : isText

-t : tag

-u: id

-W: unWrap

-w: stringQuoted

-x: prettyStringDitaHeaders

-X: cut

-z: prettyStringNumbered.

288 opUnwrap - ++ : Unwrap a node.

289 opWrapContentWith - * : Wrap content with a tag, returning the wrapping node.

290 opWrapWith - / : Wrap node with a tag, returning the wrapping node.

291 ordered - Return the first node if the specified nodes are all in order when performing a pre-ordered traversal of the parse tree else return undef.

292 over - Confirm that the string representing the tags at the level below the specified $node match a regular expression where each pair of tags is separated by a single space.

293 over2 - Confirm that the string representing the tags at the level below the specified $node match a regular expression where each pair of tags have two spaces between them and the first tag is preceded by a single space and the last tag is followed by a single space.

294 overAllTags - Return the specified b<$node> if all of it's child nodes match the specified <@tags> else return undef.

295 overFirstTags - Return the specified b<$node> if the first of it's child nodes match the specified <@tags> else return undef.

296 overLastTags - Return the specified b<$node> if the last of it's child nodes match the specified <@tags> else return undef.

297 parentOf - Returns the specified $parent node if it is the parent of the specified $child node and the $parent node is in the specified optional context.

298 parse - Parse input XML specified via: inputFile, input or inputString.

299 path - Return a list representing the path to a node from the root of the parse tree which can then be reused by go to retrieve the node as long as the structure of the parse tree has not changed along the path.

300 pathString - Return a string representing the path to the specified $node from the root of the parse tree.

301 position - Return the index of the specified $node in the content of the parent of the $node.

302 precedingSiblingOf - Returns the specified $child node if it has the same parent as $sibling and occurs before $sibling and has the optionally specified context else returns undef.

303 present - Return the count of the number of the specified tag types present immediately under a node or a hash {tag} = count for all the tags present under the node if no names are specified.

304 prettyString - Return a readable string representing a node of a parse tree and all the nodes below it.

305 prettyStringCDATA - Return a readable string representing a node of a parse tree and all the nodes below it with the text fields wrapped with <CDATA>.

306 prettyStringContent - Return a readable string representing all the nodes below a node of a parse tree.

307 prettyStringContentNumbered - Return a readable string representing all the nodes below a node of a parse tree with numbering added.

308 prettyStringDitaHeaders - Return a readable string representing the parse tree below the specified $node with appropriate headers as determined by ditaOrganization .

309 prettyStringEnd - Return a readable string representing a node of a parse tree and all the nodes below it as a here document

310 prettyStringNumbered - Return a readable string representing a node of a parse tree and all the nodes below it with a number attached to each tag.

311 prev - Return the node before the specified $node, optionally checking the previous node's context.

312 prevIn - Return the nearest sibling node before the specified $node which matches one of the named tags or undef if there is no such sibling node.

313 prevn - Return the $n'th previous node after the specified $node optionally checking its context or undef if there is no such node.

314 prevOn - Step backwards as far as possible while remaining on nodes with the specified tags.

315 prevText - Return the node before the specified $node if it is in the optional and it is a text node otherwise undef.

316 prevTextMatches - Return the previous node to the specified $node if: it is a text mode; its text matches the specified regular expression; the specified $node is in the optional specified context.

317 prevUntil - Go to the previous sibling of the specified $node and continue backwards until the tag of a sibling node matches one of the specified @tags.

318 prevWhile - Go to the previous sibling of the specified $node and continue backwards while the tag of each sibling node matches one of the specified @tags.

319 printAttributes - Print the attributes of a node.

320 printAttributesExtendingIdsWithLabels - Print the attributes of a node extending the id with the labels.

321 printAttributesReplacingIdsWithLabels - Print the attributes of a node replacing the id with the labels.

322 printNode - Print the tag and attributes of a node.

323 propagate - Propagate new attributes from nodes that match the specified tag to all their child nodes, then unwrap all the nodes that match the specified tag.

324 putFirst - Place a cut out or new node at the front of the content of the specified $node and return the new node.

325 putFirstAsText - Add a new text node first under a parent and return the new text node.

326 putFirstAsTree - Put parsed text first under the specified $node parent and return a reference to the parsed tree.

327 putFirstCut - Cut out the $second node, place it first under the $first node and return the $second node.

328 putFirstRequiredCleanUp - Place a required cleanup tag first under a node and return the required clean up node.

329 putLast - Place a cut out or new node last in the content of the specified $node and return the new node.

330 putLastAsText - Add a new text node last under a parent and return the new text node.

331 putLastAsTree - Put parsed text last under the specified $node parent and return a reference to the parsed tree.

332 putLastCut - Cut out the $second node, place it last under the $first node and return the $second node.

333 putLastRequiredCleanUp - Place a required cleanup tag last under a node and return the required clean up node.

334 putNext - Place a cut out or new node just after the specified $node and return the new node.

335 putNextAsText - Add a new text node following the specified $node and return the new text node.

336 putNextAsTree - Put parsed text after the specified $node parent and return a reference to the parsed tree.

337 putNextCut - Cut out the $second node, place it after the $first node and return the $second node.

338 putNextRequiredCleanUp - Place a required cleanup tag after a node.

339 putPrev - Place a cut out or new node just before the specified $node and return the new node.

340 putPrevAsText - Add a new text node following the specified $node and return the new text node

341 putPrevAsTree - Put parsed text before the specified $parent parent and return a reference to the parsed tree.

342 putPrevCut - Cut out the $second node, place it before the $first node and return the $second node.

343 putPrevRequiredCleanUp - Place a required cleanup tag before a node.

344 readCompressedFile - Read the specified $file containing compressed xml and return the root node.

345 reindexNode - Index the children of a node so that we can access them by tag and number.

346 renameAttr - Change the name of an attribute in the specified $node regardless of whether the new attribute already exists or not and return the node.

347 renameAttrValue - Change the name and value of an attribute in the specified $node regardless of whether the new attribute already exists or not and return the node.

348 renew - Returns a renewed copy of the parse tree, optionally checking that the starting node is in a specified context: use this method if you have added nodes via the "Put as text" methods and wish to traverse their parse tree.

349 replaceContentWith - Replace the content of a node with the specified nodes and return the replaced content

350 replaceContentWithMovedContent - Replace the content of a specified target node with the contents of the specified source nodes removing the content from each source node and return the target node.

351 replaceContentWithText - Replace the content of a node with the specified texts and return the replaced content

352 replaceSpecialChars - Replace < > " & with &lt; &gt; &quot; &amp; Larry Wall's excellent Xml parser unfortunately replaces &lt; &gt; &quot; &amp; etc.

353 replaceWith - Replace a node (and all its content) with a new node (and all its content) and return the new node.

354 replaceWithBlank - Replace a node (and all its content) with a new blank text node and return the new node.

355 replaceWithRequiredCleanUp - Replace a node with a required cleanup message and return the new node

356 replaceWithText - Replace a node (and all its content) with a new text node and return the new node.

357 requiredCleanUp - Replace a node with a required cleanup node around the text of the replaced node with special characters replaced by symbols.

358 restore - Return a parse tree from a copy saved in a file by save.

359 save - Save a copy of the parse tree to a file which can be restored and return the saved node.

360 set - Set the values of some attributes in a node and return the node.

361 setAttr - Set the values of some attributes in a node and return the node.

362 setDepthProfile - Sets the depthProfile for every node in the specified $tree.

363 setRepresentationAsTagsAndText - Sets the representationLast for every node in the specified $tree via stringTagsAndText.

364 setRepresentationAsText - Sets the representationLast for every node in the specified $tree via stringText.

365 string - Return a dense string representing a node of a parse tree and all the nodes below it.

366 stringContent - Return a string representing all the nodes below a node of a parse tree.

367 stringExtendingIdsWithLabels - Return a string representing the specified parse tree with the id attribute of each node extended by the Labels attached to each node.

368 stringMd5Sum - Return the md5 sum of the dense string representing a node of a parse tree and all the nodes below it.

369 stringNode - Return a string representing the specified $node showing the attributes, labels and node number.

370 stringQuoted - Return a quoted string representing a parse tree a node of a parse tree and all the nodes below it.

371 stringReplacingIdsWithLabels - Return a string representing the specified parse tree with the id attribute of each node set to the Labels attached to each node.

372 stringTagsAndText - Return a string showing just the tags and text at and below a specified $node.

373 stringText - Return a string showing just the text of the text nodes (separated by blanks) at and below a specified $node.

374 stringWithConditions - Return a string representing the specified $node of a parse tree and all the nodes below it subject to conditions to select or reject some nodes.

375 succeedingSiblingOf - Returns the specified $child node if it has the same parent as $sibling and occurs after $sibling and has the optionally specified context else returns undef.

376 swap - Swap two nodes optionally checking that the first node is in the specified context and return the first node.

377 swapTags - Swap the tags of two nodes optionally checking that the first node is in the specified context and return ($first, $second) nodes.

378 swapTagWithParent - Swap the tags of the specified $node and its parent optionally checking that the $node is in the specified context and return (parent of $node, $node) or () if there is no such parent node.

379 through - Traverse parse tree visiting each node twice calling the specified sub $before as we go down past the node and sub $after as we go up past the node, finally return the specified starting node.

380 throughX - Identical to through except the $before, $after subs are called in an eval block to prevent die terminating the traversal of the full tree.

381 to - Return a list of the sibling nodes preceding the specified node optionally including only those nodes that match one of the tags in the specified list.

382 tocNumbers - Table of Contents number the nodes in a parse tree.

383 topicTypeAndBody - Topic type and corresponding body.

384 tree - Build a tree representation of the parsed XML which can be easily traversed to look for things.

385 undoSpecialChars - Reverse the results of calling replaceSpecialChars.

386 unwrap - Unwrap the specified $node by inserting its content into its parent at the point containing the specified $node and return the parent node.

387 unwrapContentsKeepingText - Unwrap all the non text nodes below the specified $node adding a leading and a trailing space to prevent unwrapped content from being elided and return the specified $node else undef if not in the optional context.

388 unwrapParentsWithSingleChild - Unwrap any immediate ancestors of the specified $node which have only a single child and return the specified $node regardless.

389 up - Return the parent of the current node optionally checking the parent node's context or return undef if the specified $node is the root of the parse tree.

390 upn - Go up the specified number of levels from the specified $node and return the node reached optionally checking the parent node's context or undef if there is no such node.

391 upThru - Go up the specified path from the specified $node returning the node at the top or undef if no such node exists.

392 upUntil - Return the nearest ancestral node to the specified $node that matches the specified @context or undef if there is no such node.

393 upUntilFirst - Move up from the specified $node until we reach the root or a first node.

394 upUntilIsOnlyChild - Move up from the specified $node until we reach the root or another only child.

395 upUntilLast - Move up from the specified $node until we reach the root or a last node.

396 upWhile - Go up one level from the specified $node and then continue up while each node matches on of the specified <@tags>.

397 upWhileFirst - Move up from the specified $node as long as each node is a first node or return undef if the specified $node is not a first node.

398 upWhileIsOnlyChild - Move up from the specified $node as long as each node is an only child or return undef if the specified $node is not an only child.

399 upWhileLast - Move up from the specified $node as long as each node is a last node or return undef if the specified $node is not a last node.

400 wordStyles - Extract style information from a parse tree representing a word document.

401 wrapContentWith - Wrap the content of the specified $node in a new node created from the specified <@tag> and %attributes: the specified $node then contains just the new node which, in turn, contains all the content of the specified $node.

402 wrapDown - Wrap the content of the specified $node in a sequence of new nodes forcing the original node up - deepening the parse tree - return the array of wrapping nodes.

403 wrapFrom - Wrap all the nodes from the $start node to the $end node with a new node created from the specified <@tag> and %attributes and return the new node.

404 wrapFromFirst - Wrap this $node and any preceding siblings with a new node created from the specified <@tag> and %attributes and return the wrapping node.

405 wrapRuns - Wrap consecutive runs of children under the specified parent $node that are not already wrapped with $wrap.

406 wrapSiblingsAfter - If there are any siblings after the specified $node, wrap them with a new node created from the specified <@tag> and %attributes.

407 wrapSiblingsBefore - If there are any siblings before the specified $node, wrap them with a new node created from the specified <@tag> and %attributes.

408 wrapSiblingsBetween - If there are any siblings between the specified $nodes, wrap them with a new node created from the specified <@tag> and %attributes.

409 wrapTo - Wrap all the nodes from the $start node to the $end node inclusive with a new node created from the specified <@tag> and %attributes and return the new node.

410 wrapToLast - Wrap this $node and any following siblings with a new node created from the specified <@tag> and %attributes and return the wrapping node.

411 wrapUp - Wrap the specified $node in a sequence of new nodes created from the specified @tags forcing the original node down - deepening the parse tree - return the array of wrapping nodes.

412 wrapWith - Wrap the specified $node in a new node created from the specified $tag and %attributes forcing the specified $node down - deepening the parse tree - return the new wrapping node.

413 writeCompressedFile - Write the parse tree starting at $node as compressed xml to the specified $file.

414 xmlHeader - Add the standard xml header to a string

Installation

This module is written in 100% Pure Perl and, thus, it is easy to read, comprehend, use, modify and install via cpan:

  sudo cpan install Data::Edit::Xml

Author

philiprbrenan@gmail.com

http://www.appaapps.com

Copyright

Copyright (c) 2016-2018 Philip R Brenan.

This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself.