Reverse detail from Kakelbont MS 1, a fifteenth-century French Psalter. This image is in the public domain. Daniel Paul O'Donnell

Forward to Navigation

Using normalize-space to fix Oxygen "pretty print" spacing problems

Posted: Jun 30, 2016 17:06;
Last Modified: Jun 30, 2016 17:06

---

This is a straightforward thing for people who know what they are doing. It is only a reminder to me, who didn’t.

The journals I publish using TEI XML use the tei:figDesc element to populate the alt and title attributes of html:img.

Until today, these results in very odd looking tool tips, where the text was spread all over the place, e.g.

The problem was being caused by the OxygenXML editor’s pretty-print feature and how that was being transformed to the title and alt attributes. I was extracting the contents of the element and putting them on the attribute, this was not stripping the white space, meaning that the text showed up with strange spacing and returns.

The solution was very easy: surround the content-call with normalize-space(). Then everything worked fine. Here’s the relevant bit of XSLT:

<xsl:variable name="title">Click for full-sized image<xsl:if test="../tei:figDesc">
                        of <xsl:value-of select="../tei:figDesc"/></xsl:if></xsl:variable>
                <a href="{@url}" style="text-decoration:none;border:0px;">
                    <img alt="{../tei:figDesc}" src="{@url}" title="{normalize-space($title)}">
                        <xsl:call-template name="attcore"/>
                    </img>
----  

Back to content

Search my site

Sections

Current teaching

Recent changes to this site

Tags

anglo-saxon studies, caedmon, citation, citation practice, citations, composition, computers, digital humanities, digital pedagogy, exercises, grammar, history, moodle, old english, pedagogy, research, student employees, students, study tips, teaching, tips, tutorials, unessay, universities, university of lethbridge

See all...

Follow me on Twitter

At the dpod blog