Data-Edit-Xml-To-Dita

 view release on metacpan or  search on metacpan

lib/Data/Edit/Xml/To/DitaVb.pm  view on Meta::CPAN

#!/usr/bin/perl -I/home/phil/perl/cpan/DataTableText/lib/ -I/home/phil/perl/cpan/GitHubCrud/lib/ -I/home/phil/perl/cpan/DataEditXmlXref/lib/ -I/home/phil/perl/cpan/DitaGBStandard/lib/ -I/home/phil/perl/cpan/FlipFlop/lib/
#-------------------------------------------------------------------------------
# Data::Edit::Xml::To::Dita - Convert multiple Xml documents in parallel to Dita
# Philip R Brenan at gmail dot com, Appa Apps Ltd Inc., 2019
#-------------------------------------------------------------------------------
# podDocumentation

package Data::Edit::Xml::To::DitaVb;
our $VERSION = 20190708;
use warnings FATAL => qw(all);
use strict;
use Carp qw(confess cluck);
use Data::Dump qw(dump);
use Data::Edit::Xml;
use Data::Edit::Xml::Lint;
use Data::Edit::Xml::Xref;
use Data::Table::Text qw(:all);
use Dita::GB::Standard qw(:all);
use Flip::Flop;
use GitHub::Crud;
use Scalar::Util qw(blessed);
use Time::HiRes qw(time);
use utf8;

#D1 Convert Xml to the Dita standard.                                           # Convert Xml to the Dita standard.

sub changeBadXrefToPh{0}                                                        #I Change xrefs being placed in M3 by L<Data::Edit::Xml::Xref> to B<ph>.
sub clearCount       {&develop ? 1e4 : 1e6}                                     # Limit on number of files to clear from each output folder.
sub client           {q()}                                                      # The name of the client
sub conversion       {&conversionName}                                          # Conversion name
sub convert          {1}                                                        # Convert documents to dita if true.
sub debug            {0}                                                        # Debug if true.
sub deguidize        {0}                                                        # 0 - normal processing, 1 - replace guids in hrefs with their target files to deguidize dita references. Given href g1#g2/id convert g1 to a file name by locating the to...
sub ditaXrefs        {0}                                                        # Convert xref hrefs expressed as just ids to dita format - useful in non Dita to Dita conversions for example: docBook
sub docSet           {1}                                                        # Select set of documents to convert.
sub download         {&develop ? 0 : 1}                                         # Download from S3 if true.
sub exchange         {&develop ? 2 : 2}                                         # 1 - upload to S3 Exchange if at 100% lint, 2 - upload to S3 Exchange regardless, 0 - no upload to S3 Exchange.
sub exchangeItems    {q()}                                                      # The items to be uploaded to the exchange folder: d - downloads, i - in, p - perl, o - out, t - topic trees. Reports are uploaded by default
sub extendedNames    {0}                                                        # Expected number of output topics or B<undef> if unknown
sub fixBadRefs       {0}                                                        # Mask bad references using M3: the Monroe Masking Method if true
sub fixDitaRefs      {0}                                                        # Fix references in a corpus of L<Dita> documents that have been converted to the L<GBStandard>.
sub fixFailingFiles  {0}                                                        # Fix failing files in the L<testFails|/testFails> folder if this attribute is true
sub fixRelocatedRefs {1}                                                        # Fix references to (re|un)located files that adhere to the GB standard.
sub fixXrefsByTitle  {0}                                                        # Fix failing xrefs by looking for the unique topic with a title that matches the text of the xref.
sub hits             {Flip::Flop::hits(0)}                                      # 1 - track hits so we can see which transformations are actually being used - normally off to avoid the overhead
sub lint             {1}                                                        # Lint output xml
sub mimajen          {0}                                                        # 1- Copy files to web, 0 - suppress
sub notify           {!&develop and &upload ? &upload : 0}                      # 1 - Broadcast results of conversion if at 100% lint, 2 - broadcast regardless of error count.
sub numberOfFiles    {undef}                                                    # Expected number of output files
sub printTopicTrees  {1}                                                        # 1 - print the parse tree before cutting out the topics
sub publish          {0}                                                        # 1 - convert Dita to Html and publish via DITA-OT if at 100% lint,  2 - publish regardless
sub restructure      {0}                                                        # 1 - Restructure results of conversion if at 100% lint, 2 - restructure regardless of error count.
sub restructurePhases{1}                                                        # Number of restructuring phases to run
sub testMode         {&develop ? 1 : 0}                                         # 1 - run development tests, 2- run standalone tests, 0 run production documents
sub titleOnly        {0}                                                        # Use only the title of topics to create GB Standard file names otherwise use the following text as well if the title is too short
sub unicode          {download}                                                 # Convert to utf8 if true.
sub upload           {&develop ? 0 : 1}                                         # Upload to S3 Bucket if true and the conversion is at 100%, 2 - upload to S3 Bucket regardless, 0 - no upload to S3 Bucket.
sub version          {q()}                                                      # Description of this run as printed in notification message and title
sub xref             {1}                                                        # Xref output xml.
sub xrefAddNavTitles {1}                                                        # Add navtitles to bookmap entries if true
sub xrefAllowUniquePartialMatches{1}                                            # Allow partial matching - i.e ignore the stuff to the right of the # in a reference if doing so produces a unique result
sub xrefMatchTopics  {0}                                                        # Either 0 for no topic matching or the percentage confidence level for topic matching
#ub relinkDitaRefs   {0}                                                        # Relink dita references that are valid in the input corpus so that they are valid in the output corpus as well.
#ub singleTopicBM    {fixDitaRefs}                                              # 1 - allow single topic book maps when cutting out topics which is required if using L<fixDitaRefs>, 0 - multiple topics required for a bookmap

sub catalog          {q(/home/phil/r/dita/dita-ot-3.1/catalog-dita.xml)}        # Dita catalog to be used for linting.
sub develop          {-e q(/home/ubuntu/) ? 0 : 1}                              # Production run if this file folder is detected otherwise development.
sub ditaBin          {fpf(qw(/home phil r dita dita-ot-3.1 bin dita))}          # Location of Dita tool
sub downloads        {fpd(&home,    qw(download))}                              # Downloads folder.
sub errorLogFile     {fpe(&perl,    qw(eee txt))}                               # Error log file.
sub exchangeHome     {fpd(qw(/home phil x aws))}                                # Home of exchange folder
sub fails            {fpd(&reports, qw(fails))}                                 # Copies of failing documents in a separate folder to speed up downloading.
sub gathered         {fpd(&home,    qw(gathered))}                              # Folder containing saved parse trees after initial parse and information gathering - pretty well obsolete
sub hitsFolder       {fpd(&home,    qw(hits))}                                  # Folder containing at method hits by process id
sub home             {&getHome}                                                 # Home folder containing all the other folders.
sub imageCache       {fpd(home,     qw(imageCache))}                            # Converted images are cached here to speed things up
sub in               {fpd(&home,    qw(in))}                                    # Input documents folder.
sub inputExt         {qw(.xml .dita .ditamap)}                                  # Extension of input files.

lib/Data/Edit/Xml/To/DitaVb.pm  view on Meta::CPAN

Convert xref hrefs expressed as just ids to dita format - useful in non Dita to Dita conversions for example: docBook


=head2 docSet

Select set of documents to convert.


=head2 download

Download from S3 if true.


=head2 downloads

Downloads folder.


=head2 endTime

End time of run in seconds since the epoch.


=head2 errorLogFile

Error log file.


=head2 exchange

1 - upload to S3 Exchange if at 100% lint, 2 - upload to S3 Exchange regardless, 0 - no upload to S3 Exchange.


=head2 exchangeHome

Home of exchange folder


=head2 exchangeItems

The items to be uploaded to the exchange folder: d - downloads, i - in, p - perl, o - out, r - reports


=head2 extendedNames

0 - derive names solely from titles, 1 - consider text beyond the title when constructing file names


=head2 fails

Copies of failing documents in a separate folder to speed up downloading.


=head2 fixBadRefs

Mask bad references using M3: the Monroe Masking Method if true


=head2 fixDitaRefs

Fix references in a corpus of L<Dita|http://docs.oasis-open.org/dita/dita/v1.3/os/part2-tech-content/dita-v1.3-os-part2-tech-content.html> documents that have been converted to the L<GB Standard|http://metacpan.org/pod/Dita::GB::Standard>.


=head2 fixFailingFiles

Fix failing files in the L<testFails|/testFails> folder if this attribute is true


=head2 fixXrefsByTitle

Fix failing xrefs by looking for the unique topic with a title that matches the text of the xref.


=head2 gathered

Folder containing saved parse trees after initial parse and information gathering - pretty well obsolete


=head2 hits

1 - track hits so we can see which transformations are actually being used - normally off to avoid the overhead


=head2 hitsFolder

Folder containing at method hits by process id


=head2 home

Home folder containing all the other folders.


=head2 imageCache

Converted images are cached here to speed things up


=head2 in

Input documents folder.


=head2 inputExt

Extension of input files.


=head2 lint

Lint output xml


=head2 maximumFileFromStringLength

Maximum amount of title to use in constructing output file names.


=head2 maximumNumberOfFilesToClear

Maximum number of files to clear.



( run in 1.433 second using v1.01-cache-2.11-cpan-8dfa8b56332 )