I am trying create a routine that pre-processes a template to verify that all entered LINQ reports tags exist in the data sets available. (when I say report tags I mean this: <<[ColumnName]>>)
Is anyone able to tell me if there is a method or filter I can pass to the document GetChildNodes method to get this information? (StructuredDocumentTag does not work)
Unfortunately, LINQ Reporting Engine does not provide such functionality at the moment. This feature was already requested, it was logged as WORDSNET-17454, but for now, its development is postponed. You will be notified through the forum thread, once it is implemented.
As a workaround, to find contents of simple expression tags, you can use Range.Replace
functionality on a template document (without actual replacing) as follows:
DocumentBuilder builder = new DocumentBuilder();
builder.Write("Some text <<[Column1]>>, more text <<[Column2]>>, and some more text.");
ColumnNameCollector collector = new ColumnNameCollector();
Regex regex = new Regex(@"<<\[(.*?)\]>>");
builder.Document.Range.Replace(regex, "", new FindReplaceOptions(collector));
foreach (string columnName in collector.ColumnNames)
Console.WriteLine(columnName);
Console.WriteLine(builder.Document.GetText().Trim()); // Prints the same text, it is not replaced.
internal class ColumnNameCollector : IReplacingCallback
{
public ReplaceAction Replacing(ReplacingArgs args)
{
ColumnNames.Add(args.Match.Groups[1].Value);
// We do not want to replace anything, so skip the match.
return ReplaceAction.Skip;
}
internal List<string> ColumnNames { get; } = new List<string>();
}