Skip to content

Repository files navigation

TX Text Control Template Dependency Checker

Checks TX Text Control templates for dependencies that are missing from the runtime environment or from the template contract.

What It Checks

  • Fonts that are not available and trigger AdaptFont.
  • Referenced images whose FileName points 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_.

Basic Usage

usingTXTextControl.DocumentServer.Validation;varchecker=newTemplateDependencyChecker();TemplateDependencyInfoinfo=checker.Check("test.tx",TXTextControl.StreamType.InternalUnicodeFormat);

Check Against JSON Data

usingTXTextControl.DocumentServer.Validation;conststringjsonData="""{ "customer": { "name": "Text Control", "firstName": "Text" }, "lineItems": []}""";varchecker=newTemplateDependencyChecker();TemplateDependencyInfoinfo=checker.Check("test.tx",TXTextControl.StreamType.InternalUnicodeFormat,jsonData);

Reading Results

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}");}}

Matching Rules

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.

Run The Sample

cd tx-check-template-dependencies
dotnet run

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages