Forum How do I...?

...pull endnotes from a different file to become footnotes?

williamle8300
Hi everybody. My document doesn't have the footnotes embedded in the main body, but I'd like to implement them in my project.

For the notes I had used anchor links (numbers) which took the user to another HTML file in order to view the appropriate endnotes. My question is... Is there a way to pull the endnotes from a different file to become footnotes in the main text?
mikeday
Probably not with just CSS, no. This will require a separate program. Perhaps in the future it can be done with JavaScript directly within Prince, but currently JavaScript cannot load external files.
jim_albright
I would do it with XSLT as a preprocess to Prince.

Jim Albright
Wycliffe Bible Translators

williamle8300
Thanks for the reply, guys.

I make academic ebooks and since they are flowable, and also clickable, endnotes are the best implementation for notes.

As a suggestion, can this functionality could be added to the Prince roadmap? It would greatly help "digital first" publishing houses like mine create print equivalents easily... especially for our genre since they typically have a significant amount of footnotes. Copy/pasting them into the main body gets to impractical if there's more than a dozen footnotes.

@Jim: I don't have any experience using XSLT. Could you point me in the right direction to learn how to do this? Thanks!
jim_albright
Any scripting language will do. Use what you are familiar with.

If you really want to look at XSLT then Michael Kay's books are authoritative and Jeni Tennison's are great. I would suggest using Saxon, the free version. Also to find your specific problem's solution try googling something like
xslt footnotes endnotes

There are lots of free resources online.

Docbook is a major standard that will have lots of solutions already done if you data is in Docbook format.

XSLT has a steep learning curve if you are not familiar with functional programming.

Jim Albright
Wycliffe Bible Translators

jim_albright
If this is your only problem to solve you may find it quicker to pay someone to write the XSLT for you. Most XSLT programs cost me less than a day to create.

Jim Albright
Wycliffe Bible Translators

jim_albright
The solution would contain something along the order of:

<xsl:template match="note">
<span class="footnote">
<xsl:copy-of select="document(identify document path here)/yyy"/>
</span>
</xsl:template>

where yyy is the link into the other file. So you mainly just copy the current file until you reach a "note" at which point you pull the data (copy it) from the other file and insert in current location.

See identity template.

Jim Albright
Wycliffe Bible Translators

williamle8300
Thanks for the help, Jim! I'm not the best programmer but I'm going to see if I can do it myself. I'll let you know if I need your help.