Page 1 of 1

footnote/reference numbering synchronisation

Posted: Mon May 19, 2014 2:41 pm
by afuchs
Dear Board Members,

In TEI documents, I have <ref> elements throughout the document targeting <note> elements representing footnotes and placed at the end of the document, over IDs, as expected.

I'd like to enumerate the notes in the authoring mode, and link them to the refs. So far the only method I've come up with involves to independent counters that are applied to the refs and to the notes independently, the former coded with a link as needed. But I can see no way to synchronise the numbering, that is to ensure that the <ref> shown in the author mode as #16 targets footnote #16 and not, say, #17 that has been promoted because #4 got deleted while its ref is still in place.

Is there an elegant solution to this, or am I currently doing my best? (Note that I am not in a position to alter the coding).

Thank you in advance.

Re: footnote/reference numbering synchronisation

Posted: Mon May 19, 2014 4:12 pm
by afuchs
For the protocol: preliminary solution found.

Code: Select all

ref[target]:before {
    font-size: 70%;
    vertical-align: top;
    link: oxy_concat(oxy_base-uri(), "#", attr("target"));
    content: oxy_xpath(
        "if (exists(//note[@xml:id eq '", attr(target), "'])) then",
        "  count(//note[@xml:id eq '", attr(target), "']/preceding-sibling::note) + 1", "  else '-?-'"

Simply put, every time it has to give a number to a ref, it counts the number of notes preceding the note referenced (which is found by oxy_xpath over its given ID).
If no note is foun with the given ID, a question mark is displayed.

Re: footnote/reference numbering synchronisation

Posted: Wed May 21, 2014 9:49 am
by Radu
Hi Alexey,

I think you found the only solution which can be adopted without writing any Java code.
One problem with your solution is that oxy_xpath may induce delays when editing very large XML documents in the Author visual editing mode. This happens because Oxygen needs to reconfigure the document in more places because the oxy_xpath can take content from any part of the document or even from external resources. So if at some point you will have typing delays in large XML documents, such CSS customizations might be to blame.

We also have Java API which would allow you to write a customization and achieve a similar effect so if you will be interested in this approach we will give you more details.