EpiDoc / EFES

EFES (EpiDoc Front End Services) is a custom and readily customizable platform for publication and search/indexing of EpiDoc files, based on the Kiln platform
Apache License 2.0
31 stars 38 forks source link

Apply templates to title #64

Closed IreneVagionakis closed 2 years ago

IreneVagionakis commented 2 years ago

I would like to apply templates (in particular the one that renders the <foreign> elements in italics) to titleStmt/title, but in EFES the <xsl:template name="xxx-structure"> inside htm-tpl-struct-xxx-.xsl (which includes in my cases a <xsl:apply-templates select="$title"/>) seems to be overridden by the <kiln:block>s in webapps/ROOT/assets/templates/base.xml / webapps/ROOT/assets/templates/epidoc.xml (as for the title, specifically the blocks <kiln:block name="page-header"> at ll. 79-87 of the former and <kiln:block name="page-heading"> at ll. 36-38 of the latter). I tried to replace the <xsl:value-of select="$title" /> at l. 37 of assets/templates/epidoc.xml with <xsl:apply-templates select="$title" />, but in this way the stylesheets are looping because of the many nested <xsl:apply-templates>. The only way that I found to obtain what I wanted was to comment out l. 37 of assets/templates/epidoc.xml and to include the <xsl:apply-templates select="$title"/> directly at the beginning of the <xsl:template name="xxx-body-structure"> inside htm-tpl-struct-xxx-.xsl, but this affects in EFES the rendering of all titles in all templates structure files (hiding the title unless each template structure has the <xsl:apply-templates select="$title"/> inside the <xsl:template name="xxx-body-structure">). What is the best approach to solve this?

ajenhl commented 2 years ago

If you are modifying the xsl:template that generates the title to generate a tree rather than a string (eg, has HTML rendering of tei:foreign in it), then you need to use xsl:copy-of rather than xsl:value-of. You should be able to just change the epidoc.xml template file in this way to get what you want.

IreneVagionakis commented 2 years ago

Thanks! In this way it does not apply the general template matching t:foreign that is in webapps/ROOT/kiln/stylesheets/epidoc/htm-teiforeign.xsl, but it works if I add inside htm-tpl-struct-xxx.xsl a moded template matching t:foreign, like this:

   <xsl:template match="t:title//t:foreign" mode="inslib-foreign-title">
       <i><xsl:apply-templates/></i>
   </xsl:template>

   <xsl:template name="inslib-title">
      <xsl:choose>
        <!-- ... -->
        <xsl:when test="//t:titleStmt/t:title/node()">
          <xsl:apply-templates select="//t:titleStmt/t:title" mode="inslib-foreign-title"/>
        </xsl:when>
        <!-- ... -->
      </xsl:choose>
    </xsl:template>

Is this ok?

ajenhl commented 2 years ago

The reason it doesn't work as you expect without adding in a moded template and a mode to the apply-templates is because the parm-edn-structure parameter is not being passed in the call to inslib-title, and so the wrong path is chosen in htm-teiforeign.xsl. If you change assets/templates/epidoc-inslib.xml so that the template is called as:

`

</xsl:call-template>`

then the correct code path will be followed.

It might be worth changing all of the -title calls in the specific epidoc-.xml templates to include all of the params that are passed through in the *-body-structure calls.

IreneVagionakis commented 2 years ago

Wonderful, thanks: everything works as expected now.