Source+Templates+-+Field+Count

The complexity of a Source Template is somewhat proportional to the number of fields and their distribution between the Master Source and Source Details (citation-specific). It is probable that a source with a greater number of fields in total AND a greater number of them in Source Details will be more complex than one that has lesser numbers and will suffer more distortion and loss when exported to standard GEDCOM (see ). There are other factors that complicate the fidelity of export which could well result in some exceptions but they are harder to measure. These include: This query does the easy task of counting the total number of fields and the number of those that are Source Detail fields.
 * fields in the RM Footnote sentence template out of order from the simple convention of Master fields first followed by Source Detail fields
 * words or strings that are within a sentence template switch that are conditional on a non-empty Source Detail field



code format="sql" -- SourceTemplates-FieldCount.sql -- 2013-04-08 Tom Holden ve3meo /* Converts the FieldDefs blob from SourceTemplateTable to a 1-line string and counts the number of occurrences of "" in it (the number of fields) and the subset of same that are Source Detail fields "True". Does so by measuring the lengths of the FieldDefsTxt strings with and without the search string and dividing the difference by the length of the search string. DROP TABLE IF EXISTS xSrcTpltFldDefs;

CREATE TEMP TABLE IF NOT EXISTS xSrcTpltFldDefs AS	SELECT TemplateID ,NAME ,REPLACE(REPLACE(CAST(FieldDefs AS TEXT), x '0A', ), x '0D', ) AS FieldDefsTxt FROM SourceTemplateTable;

SELECT TemplateID ,NAME ,(LENGTH(FieldDefsTxt) - LENGTH(REPLACE(FieldDefsTxt, '', ''))) / LENGTH('') AS TotalFields ,(LENGTH(FieldDefsTxt) - LENGTH(REPLACE(FieldDefsTxt, 'True', ''))) / LENGTH('True') AS SrcDtlFields ,FieldDefsTxt FROM xSrcTpltFldDefs; code