Digital-Humanities-Quarterly / dhq-journal

DHQ is an open-access, peer-reviewed journal of digital humanities.
http://www.digitalhumanities.org/dhq/
10 stars 5 forks source link

adding additional checks on @target of <ref> #60

Closed brgrey closed 5 months ago

brgrey commented 5 months ago

Following a discussion at the weekly production meeting on January 12, this (small) Schematron update adds a rule which checks for intended values of @target in the context of <ref>.

Its aim is to ensure that when @target begins with a '#' (i.e., it is an internal document link) it points to an existing @xml:id somewhere in the document. The purpose of this assertion is to help eliminate encoding spelling errors when <ref> is used to point to a <bibl>, as well as ensure that internal links to elements like sections, figures, tables, and whatever else we assign @xml:id values to actually lead readers to their intended destination.

Following the merge of this request, a realistic next step would be to generate a report of <ref> elements which fail this new assertion, to aid in fixing broken links within the article corpus.

amclark42 commented 5 months ago

I haven't tested the code but it looks good! The only change I'd make is to make sure that <name/> is reported as plain text. To do so, all you have to do is make sure the pointy brackets are encoded with &lt; and &gt;, e.g. &lt;name/&gt;.

(I'm not sure what would happen if this message were flagged as it currently stands. I suspect the empty element would translate into an empty string: The target of does not reference....)

brgrey commented 5 months ago

@amclark42, that <name/> element you're referencing actually parses the name of the element in which the rule is acting (i.e., <ref>, so that the warning message reads: The @target of ref does not reference an @xml:id in this document.

amclark42 commented 5 months ago

@brgrey Gotcha!