The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

Name

Dita::Validate - In situ validation of XML parse trees representing OASIS DITA documents.

Synopsis

Parse some XML representing a document that almost conforms to DITA:

  use Data::Edit::Xml;
  use Dita::Validate;

  my $x = Data::Edit::Xml::new(<<END);
<ol>
<li><p>ppp</p></li>
<li><q>qqq</q></li>
<li><conbody>ccc</conbody></li>
</ol>
END

Validate the XML tree structure against the DITA standard and diagnose any errors in situ:

  if (my $r = Dita::Validate::allChildren($x))
   {
    ok $r->last->tag eq q(li);
    ok $r->fail->tag eq q(conbody);
    ok $r->reason    eq q(Tag: conbody cannot appear first under tag: li);
    ok join(" ", @{$r->next}) =~ m(b boolean cite cmdname codeblock);
   }

This approach avoids the need to: construct a complete DITA topic, write the topic to a file, apply xmllint to the file containing the topic and then manually connect the resulting error messages back to the failing nodes in the parse tree.

This module does not require you to install DITA-OT or xmllint. To apply xmllint to a large number of files see: Data::Edit::Xml::Lint.

The deterministic finite state automatons used internally to validate the XML representing DITA conforming documents were obtained by parsing the Normative Form of the DITA specification with Data::Edit::Xml and then applying Data::NFA and Data::DFA.

Description

In situ validation of XML parse trees representing OASIS DITA documents.

Version q(20181027).

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

Index

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 Dita::Validate

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.