view release on metacpan or search on metacpan
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
otherMetaDuplicatesCombined => [], # Duplicate othermeta in bookmaps with called topics othermeta included
otherMetaRemainWithTopic => [], # Othermeta that must stay in the topic
otherMetaPushToBookMap => [], # Othermeta that can be pushed to the calling book map
otherMetaBookMapsBeforeTopicIncludes=> [], # Bookmap othermeta before topic othermeta has been included
otherMetaBookMapsAfterTopicIncludes => [], # Bookmap othermeta after topic othermeta has been included
otherMetaConsolidated => {}, # {Name}{Content}++ : consolidated other meta data across entire corpus
oxygenProjects => undef, #I Create oxygen project files for each map - the project file will have an extension of .xpr and the same name and path as the map file or the name return by your implem...
parseFailed => {}, # {file} files that failed to parse.
publicId => {}, # {file} = Public id on Doctype
references => {}, # {file}{reference}++ - the various references encountered
relocatedReferencesFailed => [], # Failing references that were not fixed by relocation
relocatedReferencesFixed => [], # Relocated references fixed
requestAttributeNameAndValueCounts => undef, #I Report attribute name and value counts
requiredCleanUp => undef, # {full file name}{cleanup} = number of required-cleanups
reports => undef, #I Reports folder: Xref will write text versions of the generated reports to files in this folder.
results => [], # Summary of results table.
# sourceFile => undef, # The source file from whic#h this structure was generated.
sourceTopicToTargetBookMap => {}, # {input topic cut into multiple pieces} = output bookmap representing pieces
statusLine => undef, # Status line summarizing the cross reference.
statusTable => undef, # Status table summarizing the cross reference.
subjectSchemeMap => undef, #I Create a subject scheme map in the named file
suppressReferenceChecks => undef, #I Suppress reference checking - which normally happens by default - but which takes time and might be irrelevant if an earlier xref has already checked all the reference...
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
}
owf($out, join '', @h, $source, @l) # Insert new source between old headers and trailers
}
# Fix a file by moving its hrefs and conrefs to the xtrf attribute unless
# deguidization is in effect and the guid can be converted into a valid Dita
# reference accessing a file in the input corpus.
#
# If fixRelocatedRefs is in effect: such references are fixed by assuming that
# the files mentioned in broken links have been relocated else where in the
# folder structure and can be located by base file name alone.
#
# If fixXrefsByTitle is in effect apply the Gearhart Title Method: fix broken
# xrefs by looking for a unique topic with the same title text as the content of
# the xref.
#
# If fixDitaRefs is in effect we are converting Dita to Dita: relink Dita
# references that were valid in the input corpus to make them valid again in the
# output corpus even after files have been cut out and renamed to the GB Standard.
# The targets/ folder provides the mapping between the input and output corpii.
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
}
}
if ($xref->allowUniquePartialMatches && $attr !~ m(\Aconref)s) # Partial matching - i.e ignoring the stuff to the right of the # in the reference sometimes produces a unique result.
{return &$fixOnePartialDitaRef($ref =~ s(#.*\Z) ()rs); # Try to resolve reference as a partial re
}
undef # Failed
};
my $fixRelRef = sub # Attempt to fix a reference broken by relocation
{my ($R, $rest) = split m(#)s, $ref, 2; # Get referenced file name
if ($R)
{my $r = fne($R); # Href file base name
if (my $F = $xref->baseFiles->{$r}) # Relocated else where
{my @targets = sort keys(%$F); # Relocation targets
if (@targets == 1) # Just one such relocation
{my $f = relFromAbsAgainstAbs($targets[0], $sourceFile); # Link to it
if ($f ne $R)
{my $newLink; # Fix if the target is else where
if ($rest) # Link has more than one component
{$node->set($attr=>($newLink = $f.q(#).$rest)); # Reset link
}
else # Link has just one component
{$node->set($attr=>($newLink = $f)); # Reset link
}
my $saveRef = $ref; $ref = $newLink; # Try fixing the relocated reference as a dita reference.
my $r = &$fixOneFullDitaRef;
$ref = $saveRef;
return $r;
}
}
}
}
undef # Failed
};
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
else
{push @unresolved, $subRef;
}
}
if (@unresolved and $xref->fixBadRefs) # Unresolved - transfer all references to xtrf so some-one else can try
{$node->renameAttr($attr, q(xtrf)); # No target file for guid
&$bad(q(No file for guid)); # Report failure
}
}
elsif ($xref->fixRelocatedRefs and &$fixRelRef) # Try to fix as a relocated ref if possible
{
}
elsif ($xref->fixXrefsByTitle and &$fixXrefByTitle) # Try to fix a missing xref by title
{
}
elsif ($xref->fixBadRefs) # Move href to xtrf as no other fix seems possible given that we have already tried to fix it as a guid and it was reportedly not working as a standard dita reference.
{$node->renameAttr($attr, q(xtrf)); # No target file for guid
if ($xref->changeBadXrefToPh) # Change bad xref to ph if requested
{if ($node->at_xref)
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
This represents a flattening factor of: $f (higher is better) in the topics that got flattened
Total number of topics : $n
Number of topics flattened: $t
Percent topics flattened: $p
END
file => fpe(qw(lists topic_flattening txt)));
}
}
if ($xref->fixRelocatedRefs) # Load base file name to full name but if needed to do relocation fixes
{my %baseFiles; # Map base files back to full files. The base file is the file name shorn of the path - the reason the GB Standard is so important
for my $file(searchDirectoryTreesForMatchingFiles($xref->inputFolder)) # All input files
{my $base = fne $file; # Base file name - the GB Standard name for the file
$baseFiles{$base}{$file}++; # Current location of the file
}
$xref->baseFiles = \%baseFiles;
}
my @bad; # Hrefs that could not be fixed and so were ameliorated by moving them to @xtrf
my @good; # Hrefs that were fixed by resolving a Guid
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
The presence of the input attribute:
flattenFolder => folder-to-flatten-files-into
causes topic files to be flattened into the named folder using the
L<GBStandard> to generate the flattened file names. Xref will then update all
L<Dita> references to match these new file names. If the L<flattenFolder>
folder is the same as the L<inputFolder> then the input files are flattened in
place.
=head2 Locating relocated files
File references in B<conref> or B<hrefs> that have a unique valid base file
name and an invalid path can be fixed by setting the input attribute:
fixRelocatedRefs => 1
to a true value to request that Xref should replace the incorrect paths to the
unique bases file names with the correct path.
If coded in conjunction with the B<fixBadRefs> input attribute this will cause
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
B<otherMetaPushToBookMap> - Othermeta that can be pushed to the calling book map
B<otherMetaRemainWithTopic> - Othermeta that must stay in the topic
B<parseFailed> - {file} files that failed to parse.
B<publicId> - {file} = Public id on Doctype
B<references> - {file}{reference}++ - the various references encountered
B<relocatedReferencesFailed> - Failing references that were not fixed by relocation
B<relocatedReferencesFixed> - Relocated references fixed
B<requiredCleanUp> - {full file name}{cleanup} = number of required-cleanups
B<results> - Summary of results table.
B<sourceTopicToTargetBookMap> - {input topic cut into multiple pieces} = output bookmap representing pieces
B<statusLine> - Status line summarizing the cross reference.
B<statusTable> - Status table summarizing the cross reference.
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
</concept>
END
owf(fpe($in, qw(c dita)), <<END);
$conceptHeader
<concept id="c">
<title>C2</title>
<conbody>
<p conref="$r#c/p1"/>
<p conref="$r#c1/p1"/> <!-- PASSES: wrong topic id but we ignore topic ids-->
<p conref="$r#c/bad"/> <!-- PASSES: no such id - SHOULD FAIL even though we are relocating -->
<p conref="$r"/>
<p conref="c.dta"/> <!-- FAILS: no such file -->
<p id="q1">aaa</p>
<p conref="#c/q1"/>
</conbody>
</concept>
END
}
sub checkXrefStructure($$@) #P Check an output structure produced by Xrf
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
"bm_b_d2806ba589f908da1106574afd9db642.ditamap" => {
"c_bbbb_6100b51ca1f789836cd4f31893ed67d2.dita" => 1,
"c_bbbb_aaaa_cfd3a140e06a914fc8469583ad87829d.dita" => 1,
"c_bbbb_bbbb_c90ebf976073b2a3f7a8dc27a3c8254b.dita" => 1,
"c_bbbb_cccc_d1c80714275637cde524bdfa1304a8f3.dita" => 1,
},
"c_aaaa_bbbb_55baefe9258538b26a95b0015a8d5a2b.dita" => { p1 => 1 },
"c_aaaa_cccc_a91633094220d068c453eecae1726eff.dita" => { p2 => 1 },
"c_aaaa_dddd_914b8e11993908497768c50d992ea0f0.dita" => { p3 => 1 },
},
relocatedReferencesFailed => [],
relocatedReferencesFixed => [],
reports => '',
requestAttributeNameAndValueCounts => undef,
requiredCleanUp => {},
results => [[1, "ref"]],
sourceTopicToTargetBookMap => {
"a.xml" => bless({
source => "a.xml",
sourceDocType => "concept",
target => "bm_a_9d0a9f8e0ac234de9e22c19054b6e455.ditamap",
targetType => "bookmap",
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
otherMetaBookMapsBeforeTopicIncludes => [],
otherMetaConsolidated => {},
otherMetaDuplicatesCombined => [],
otherMetaDuplicatesSeparately => [],
otherMetaPushToBookMap => [],
otherMetaRemainWithTopic => [],
oxygenProjects => undef,
parseFailed => {},
publicId => { "c1.dita" => undef, "c2.dita" => undef },
references => {},
relocatedReferencesFailed => [],
relocatedReferencesFixed => [],
reports => '',
requestAttributeNameAndValueCounts => undef,
requiredCleanUp => {
"c1.dita" => { aaa => 1, bbb => 2 },
"c2.dita" => { aaa => 1, bbb => 1, ccc => 1, CCC => 1 },
},
results => [[2, "first lines"], [2, "second lines"]],
sourceTopicToTargetBookMap => {},
statusLine => "Xref: 2 first lines, 2 second lines",
statusTable => " Count Condition\n1 2 first lines\n2 2 second lines\n",
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
references => {
"c.dita" => {
"bad" => 1,
"c.dta" => 1,
"c_12345678123456781234567812345678.dita" => 1,
"p1" => 1,
"q1" => 1,
},
"c_12345678123456781234567812345678.dita" => { p1 => 1, pp => 1 },
},
relocatedReferencesFailed => [],
relocatedReferencesFixed => [],
reports => '',
requestAttributeNameAndValueCounts => undef,
requiredCleanUp => {},
results => [[1, "duplicate id"], [6, "refs"], [1, "duplicate topic id"]],
sourceTopicToTargetBookMap => {},
statusLine => "Xref: 6 refs, 1 duplicate id, 1 duplicate topic id",
statusTable => " Count Condition\n1 6 refs\n2 1 duplicate id\n3 1 duplicate topic id\n",
subjectSchemeMap => undef,
suppressReferenceChecks => undef,
tableDimensions => {},
lib/Data/Edit/Xml/Xref.pm view on Meta::CPAN
otherMetaBookMapsBeforeTopicIncludes => [],
otherMetaConsolidated => {},
otherMetaDuplicatesCombined => [],
otherMetaDuplicatesSeparately => [],
otherMetaPushToBookMap => [],
otherMetaRemainWithTopic => [],
oxygenProjects => undef,
parseFailed => {},
publicId => { "concept.dita" => "EN" },
references => {},
relocatedReferencesFailed => [],
relocatedReferencesFixed => [],
reports => "",
requestAttributeNameAndValueCounts => undef,
requiredCleanUp => {},
results => [[2, "urls"]],
sourceTopicToTargetBookMap => {},
statusLine => "Xref: 2 urls",
statusTable => " Count Condition\n1 2 urls\n",
subjectSchemeMap => undef,
suppressReferenceChecks => undef,
tableDimensions => {},