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_.
usingTXTextControl.DocumentServer.Validation;varchecker=newTemplateDependencyChecker();TemplateDependencyInfoinfo=checker.Check("test.tx",TXTextControl.StreamType.InternalUnicodeFormat);usingTXTextControl.DocumentServer.Validation;conststringjsonData="""{ "customer": { "name": "Text Control", "firstName": "Text" }, "lineItems": []}""";varchecker=newTemplateDependencyChecker();TemplateDependencyInfoinfo=checker.Check("test.tx",TXTextControl.StreamType.InternalUnicodeFormat,jsonData);foreach(MissingFontDependencyfontininfo.MissingFonts){Console.WriteLine($"Missing font: {font.FontName}");}foreach(MissingImageDependencyimageininfo.MissingImages){Console.WriteLine($"Missing image: {image.FileName}");}if(info.DataDependenciesis{}data){foreach(MissingDocumentFieldDependencyfieldindata.MissingDocumentFields){Console.WriteLine($"Merge field missing in document: {field.Name}");}foreach(MissingDocumentMergeBlockDependencyblockindata.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