Name

Data::Edit::Xml::Xref - Cross reference Dita XML.

Synopsis

Check the references in a set of Dita XML documents held in folder inputFolder:

 use Data::Edit::Xml::Xref;

 my $x = xref(inputFolder=>q(in));
 ok nws($x->statusLine) eq nws(<<END);
Xref:
10 bad first lines,
10 bad second lines,
 9 bad conrefs,
 9 bad xrefs,
 8 duplicate ids,
 8 missing image files,
 8 missing image references,
 3 bad topicrefs,
 2 duplicate topic ids,
 1 bad book map,
 1 file failed to parse,
 1 file not referenced
END

The counts listed in the statusLine are the counts of the files that have the described problems not a count of all the instances of the problem in all the files which would be larger.

More detailed reports are produced in the reports folder:

$x->reports

Description

Cross reference Dita XML.

Version 20181204.

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

Cross reference

Check the cross references in a set of Dita files and report the results.

xref(%)

Check the cross references in a set of Dita files held in inputFolder and report the results in the reports folder. The possible attributes are defined in Data::Edit::Xml::Xref

   Parameter    Description
1  %attributes  Attributes

Example:

my $x = 𝘅𝗿𝗲𝗳(inputFolder=>q(in), fixBadRefs=>1, maximumNumberOfProcesses=>2);

Hash Definitions

Data::Edit::Xml::Xref Definition

Attributes used by the Xref cross referencer.

attributeCount - {file}{attribute} == count of the different xml attributes found in the xml files.

badBookMaps - Bad book maps

badConRefs - [file, href] Invalid conref attributes.

badImageRefs - Consolidated images missing.

badTopicRefs - [file, href] Invalid href attributes found on topicref tags.

badXRefs - [file, href] Invalid href attributes found on xref tags.

badXml1 - [Files] with a bad xml encoding header on the first line.

badXml2 - [Files] with a bad xml doc type on the second line.

conRefs - {file}{href} Count of conref definitions in each file.

docType - {file} == docType: the docType for each xml file.

duplicateIds - [file, id] Duplicate id definitions within each file.

duplicateTopicIds - [topicId, [files]] Files with duplicate topic ids - the id on the outermost tag.

fixBadRefs - Try to fix bad references in these files where possible.

fixedFiles - Files that have a missing conref or href which can be ameliorated by renaming the failing attribute to "xtrf".

goodBookMaps - Good book maps

goodConRefs - Good con refs

goodImageRefs - Consolidated images found.

goodTopicRefs - Good topic refs

goodXRefs - Good xrefs

ids - {file}{id} Id definitions across all files.

images - {file}{href} Count of image references in each file.

inputFiles - Input files from inputFolder.

inputFolder - A folder containing the dita and ditamap files to be cross referenced.

maximumNumberOfProcesses - Maximum number of processes to run in parallel at any one time.

missingImageFiles - [file, href] == Missing images in each file.

missingTopicIds - Missing topic ids

notReferenced - files in input area that are not referenced by a conref, image, topicref or xref tag and are not a bookmap.

parseFailed - [file] files that failed to parse

reports - Reports folder: the cross referencer will write reports to files in this folder.

results - Summary of results table

sourceFile - The source file from which this structure was generated

statusLine - Status line summarizing the cross reference. The counts listed in the status line are the counts of the files that have the described problems not a count of all the instances of all the problems in all the files.

summary - Print the summary line.

tagCount - {file}{tags} == count of the different tag names found in the xml files.

topicIds - {file} = topic id - the id on the outermost tag.

topicRefs - {file}{href}++ References from bookmaps to topics via appendix, chapter, topicref.

validationErrors - True means that Lint detected errors in the xml contained in the file

xRefs - {file}{href}++ Xrefs references.

Private Methods

loadInputFiles($)

Load the names of the files to be processed

   Parameter  Description
1  $xref      Cross referencer

analyzeOneFile($)

Analyze one input file

   Parameter  Description
1  $iFile     File to analyze

fixOneFile($$)

Analyze one input file

   Parameter  Description
1  $xref      Xref results
2  $file      File to fix

analyze($)

Analyze the input files

   Parameter  Description
1  $xref      Cross referencer

reportDuplicateIds($)

Report duplicate ids

   Parameter  Description
1  $xref      Cross referencer

reportDuplicateTopicIds($)

Report duplicate topic ids

   Parameter  Description
1  $xref      Cross referencer

reportBadRefs($$)

Report bad references found in xrefs or conrefs as they have the same structure

   Parameter  Description
1  $xref      Cross referencer
2  $type      Type of reference to be processed

reportBadXrefs($)

Report bad xrefs

   Parameter  Description
1  $xref      Cross referencer

reportBadTopicRefs($)

Report bad topic refs

   Parameter  Description
1  $xref      Cross referencer

reportBadConrefs($)

Report bad conrefs refs

   Parameter  Description
1  $xref      Cross referencer

reportImages($)

Reports on images and references to images

   Parameter  Description
1  $xref      Cross referencer

reportParseFailed($)

Report failed parses

   Parameter  Description
1  $xref      Cross referencer

reportBadXml1($)

Report bad xml on line 1

   Parameter  Description
1  $xref      Cross referencer

reportBadXml2($)

Report bad xml on line 2

   Parameter  Description
1  $xref      Cross referencer

reportDocTypeCount($)

Report doc type count

   Parameter  Description
1  $xref      Cross referencer

reportTagCount($)

Report tag counts

   Parameter  Description
1  $xref      Cross referencer

reportAttributeCount($)

Report attribute counts

   Parameter  Description
1  $xref      Cross referencer

reportValidationErrors($)

Report the files known to have validation errors

   Parameter  Description
1  $xref      Cross referencer

checkBookMap($$)

Check whether a bookmap is valid or not

   Parameter  Description
1  $xref      Cross referencer
2  $bookMap   Bookmap

reportBookMaps($)

Report on whether each bookmap is good or bad

   Parameter  Description
1  $xref      Cross referencer

reportFileExtensionCount($)

Report file extension counts

   Parameter  Description
1  $xref      Cross referencer

reportFileTypes($)

Report file type counts - takes too long in series

   Parameter  Description
1  $xref      Cross referencer

reportNotReferenced($)

Report files not referenced by any of conref, image, topicref, xref and are not bookmaps.

   Parameter  Description
1  $xref      Cross referencer

createSampleInputFiles($)

Create sample input files for testing. The attribute inputFolder supplies the name of the folder in which to create the sample files.

   Parameter  Description
1  $N         Number of sample files

Index

1 analyze - Analyze the input files

2 analyzeOneFile - Analyze one input file

3 checkBookMap - Check whether a bookmap is valid or not

4 createSampleInputFiles - Create sample input files for testing.

5 fixOneFile - Analyze one input file

6 loadInputFiles - Load the names of the files to be processed

7 reportAttributeCount - Report attribute counts

8 reportBadConrefs - Report bad conrefs refs

9 reportBadRefs - Report bad references found in xrefs or conrefs as they have the same structure

10 reportBadTopicRefs - Report bad topic refs

11 reportBadXml1 - Report bad xml on line 1

12 reportBadXml2 - Report bad xml on line 2

13 reportBadXrefs - Report bad xrefs

14 reportBookMaps - Report on whether each bookmap is good or bad

15 reportDocTypeCount - Report doc type count

16 reportDuplicateIds - Report duplicate ids

17 reportDuplicateTopicIds - Report duplicate topic ids

18 reportFileExtensionCount - Report file extension counts

19 reportFileTypes - Report file type counts - takes too long in series

20 reportImages - Reports on images and references to images

21 reportNotReferenced - Report files not referenced by any of conref, image, topicref, xref and are not bookmaps.

22 reportParseFailed - Report failed parses

23 reportTagCount - Report tag counts

24 reportValidationErrors - Report the files known to have validation errors

25 xref - Check the cross references in a set of Dita files held in inputFolder and report the results in the reports folder.

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::Xref

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.