[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]
Subject: Re: [docbook-apps] Generating multiple metadata elements in user.head.content
Hi Dave,
When processing an element that can appear zero or more
times, I've found that creating a template that matches on that element and then
using apply-templates works best. If there are no such elements, then the
apply-templates does nothing. If there are, it is applied as many times as
there are elements. Doing that in a new mode will
prevent any interference from existing templates.
This customization should do what you want.
<xsl:template name="user.head.content">
<xsl:param name="node" select="."/> <xsl:param name="info" select="d:info[1]"/> <xsl:apply-templates
select="$info//d:authorgroup[@role='leadauthor']/d:author" mode="author.meta.mode"/> </xsl:template> <xsl:template match="d:author" mode="author.meta.mode"> <meta name="dcterms:creator"> <xsl:attribute name="content"> <xsl:variable name="personname"> <xsl:choose> <xsl:when test="d:personname/d:surname"> <xsl:call-template name="person.name.last-first"/> </xsl:when> <xsl:otherwise> <xsl:call-template name="person.name"/> </xsl:otherwise> </xsl:choose> </xsl:variable> <xsl:value-of select="$personname"/>
</xsl:attribute>
</meta> </xsl:template> </xsl:stylesheet>
I called a couple of utility templates from common/common.xsl to arrange
the author information in a temporary variable named 'personname', and then took
the value of the result to eliminate html span wrappers and reduce it to plain
text for the attribute value.
From: Xmplar
Sent: Tuesday, August 27, 2013 6:48 PM
To: DocBook Apps
Subject: [docbook-apps] Generating multiple metadata elements in
user.head.content
<authorgroup role="leadauthor"> My first issue is trying to generate both <author> names in separate meta elements in HTML5 using 1.78.1-ns. This is all I get: <meta name="dcterms:creator" content="Smith, John" /> I have a customization that generates only the first author?s names (firstname and surname) ? I don?t get the second author, nor do I get any content inside only <personname> (so far I need both <firstname> and <surname> to generate content): <xsl:template name="user.head.content"> ? <xsl:if test="$info and
$info//d:author[ancestor::d:authorgroup[@role='leadauthor']]"> ? </xsl:template> I tried using xsl:for-each around the <meta> coding, and then again inside <meta>, but that generates the first author?s name multiple times in one <meta> element. I can?t see any clues from the EPUB metadata stylesheets either. So: (1) How do I generate one meta element *for each author*, and (2) What coding works to generate content marked up in <personname> only (i.e. no child elements)? --
Dave Gardiner |
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]