Checks TX Text Control templates for dependencies that are missing from the runtime environment or from the template contract.
- Fonts that are not available and trigger
AdaptFont. - Referenced images whose
FileNamepoints to a missing file. - JSON data fields that do not exist as merge fields or form fields in the template.
- JSON array properties that do not exist as merge blocks in the template.
- JSON array item fields that do not exist as merge fields in the template.
Merge blocks are detected from SubTextPart names that use the TX Text Control
merge block prefix txmb_.
using TXTextControl.DocumentServer.Validation;
var checker = new TemplateDependencyChecker();
TemplateDependencyInfo info = checker.Check(
"test.tx",
TXTextControl.StreamType.InternalUnicodeFormat);using TXTextControl.DocumentServer.Validation;
const string jsonData = """
{
"customer": {
"name": "Text Control",
"firstName": "Text"
},
"lineItems": []
}
""";
var checker = new TemplateDependencyChecker();
TemplateDependencyInfo info = checker.Check(
"test.tx",
TXTextControl.StreamType.InternalUnicodeFormat,
jsonData);foreach (MissingFontDependency font in info.MissingFonts)
{
Console.WriteLine($"Missing font: {font.FontName}");
}
foreach (MissingImageDependency image in info.MissingImages)
{
Console.WriteLine($"Missing image: {image.FileName}");
}
if (info.DataDependencies is { } data)
{
foreach (MissingDocumentFieldDependency field in data.MissingDocumentFields)
{
Console.WriteLine($"Merge field missing in document: {field.Name}");
}
foreach (MissingDocumentMergeBlockDependency block in data.MissingDocumentMergeBlocks)
{
Console.WriteLine($"Merge block missing in document: {block.Name}");
}
}Scalar JSON fields use exact dot-notation matching. For example,
customer.firstName must exist as customer.firstName in a merge field or form
field.
Dotted JSON fields can also be satisfied by a merge block and an inner merge
field. For example, customer.name is considered present if the template
contains a customer merge block and a merge field named name.
Merge block names are matched leniently so lineItems can match a SubTextPart
named txmb_lineItems.
cd tx-check-template-dependencies
dotnet run