OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[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


Thanks Bob, that's a nice solution. Inexplicably, calling the "person.name.last-first" template didn't apply the punctuation between surname and firstname (there was a space but no comma). I substituted in your custom template instead:

<xsl:apply-templates select="d:personname/d:surname"/>
              <xsl:text>, </xsl:text>
              <xsl:apply-templates select="d:personname/d:firstname"/>
Dave

On 29-08-13 3:12 AM, Bob Stayton wrote:
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.
 
Bob Stayton
Sagehill Enterprises
bobs@sagehill.net

From: Xmplar
Sent: Tuesday, August 27, 2013 6:48 PM
Subject: [docbook-apps] Generating multiple metadata elements in user.head.content


I have two book author names marked up in <authorgroup>:

<authorgroup role="leadauthor">
                                   
<author>
                                               
<personname><honorific>Mr</honorific><firstname>John</firstname><surname>Smith</surname></personname>
                                               
<contrib>Lead author contribution</contrib>
                                               
<affiliation>
                                                           
<shortaffil>Short affil.</shortaffil>
                                                           
<jobtitle>Job title</jobtitle>
                                                           
<orgname>Organisational affiliation</orgname>
                                                           
<orgdiv>Org div</orgdiv>
                                                           
<address>Org address</address>
                                               
</affiliation>
                                   
</author>
                                   
<author>
                                               
<personname>Name of second lead author</personname>
                                   
</author>
                       
</authorgroup>

 

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:param name="node" select="."/>
   
<xsl:variable name="info" select="(d:info)[1]"/>

<xsl:if test="$info and $info//d:author[ancestor::d:authorgroup[@role='leadauthor']]">     
     
<meta name="dcterms:creator">
         
<xsl:attribute name="content">
           
<!--<xsl:call-template name="person.name.last-first">
            <xsl:with-param name="node" select="."/>
          </xsl:call-template>-->
             
           
<xsl:choose>
             
<xsl:when test="descendant::d:surname">
               
<xsl:value-of select="normalize-space(string($info/d:authorgroup[@role='leadauthor']/d:author/d:personname/d:surname))"/>
               
<xsl:text>, </xsl:text>
               
<xsl:value-of select="normalize-space(string($info/d:authorgroup[@role='leadauthor']/d:author/d:personname/d:firstname))"/>
             
</xsl:when>
             
<xsl:otherwise>
               
<xsl:value-of select="normalize-space(string($info/d:authorgroup[@role='leadauthor']/d:author/d:personname))"/>   
             
</xsl:otherwise>
           
</xsl:choose>
         
</xsl:attribute> 
     
</meta>
     
   
</xsl:if>

</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]