TEIC / Stylesheets

TEI XSL Stylesheets
228 stars 124 forks source link

teitodocx tries to write a file from a variable iff ref to person not in particDesc #445

Open sydb opened 4 years ago

sydb commented 4 years ago

This arises from TEI ticket #2009.

OP has a TEI document which Stylesheets/bin/teitodocx chokes on. (More details on the error below.) @martindholmes discovered that the error goes away if you either delete the <listPerson> from the back matter, or move it to a <particDesc> in the header. We suspect the error occurs on processing an @ref that points to a <person> that is not in the <particDesc>, but we don’t know for sure.

The error message itself says that an attempt was made to generate a result document while evaluating a variable value. (In particular, the <xsl:result-document> on line 106 of Stylesheets/docx/to/headers.xsl.)

sydb commented 4 years ago

I have done some quick testing. It seems that a <listPerson>, no matter how small (e.g.,

<listPerson>
  <person/>
</listPerson>

) will trigger this error iff a descendant of <text>, but not as a descendant of <teiHeader> or <standOff>, whether pointed at by an @ref or not. I have not been excruciatingly thorough, but I have convinced myself the first place we should look is in the normal processing of <listPerson> and <person>. (Betting that they are either not processed by metadata processing; at least there is no error.)

sydb commented 4 years ago

I have now further tested with each of the possible list* elements as a child of <body> (i.e. <listApp>, <listBibl>, <listEvent>, <listForest>, <listNym>, <listObject>, <listOrg>, <listPerson>, <listPlace>, <listRef>, <listRelation>, <listTranspose>, and <listWit>). While most are invalid that way (they require a child), only one caused an error when running teitodocx: <listPerson>.

Since <listPerson> is only matched by 4 templates in this repo, and one of them is in docx/to/teitodocx.xsl and the other three in unlikely sounding candidates, I think we should start there.

sydb commented 4 years ago

Removing the ‘$’ on line 2947 of docx/to/teitodocx.xsl (so that it now reads <xsl:apply-templates select="mylist"/>) makes the problem go away. Of course it also means that template no longer generates any output, but depending on what is what, that may not be a bad thing.