]> granicus.if.org Git - docbook-dsssl/commitdiff
Adjusted normalization of person-names. The person.name.normalized
authorMichael Smith <xmldoc@users.sourceforge.net>
Wed, 23 Aug 2006 01:59:29 +0000 (01:59 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Wed, 23 Aug 2006 01:59:29 +0000 (01:59 +0000)
template now checks the RTF of output from person.name template
node-by-node, and does normalization only on the nodes that need
it. Also fixed normalization of email output for the metadata
comment part of the man page, such that normalization is done
before the angle brackets are added.

xsl/manpages/info.xsl
xsl/manpages/utility.xsl

index dc6999f7754287b39690f256a1ad53e904dc264e..171093cfe5cd96912b5b97c01d1b743a261f79b6 100644 (file)
       <xsl:text> </xsl:text>
       <!-- * For each attribution found, use only the first e-mail -->
       <!-- * address or ulink value found -->
-      <xsl:apply-templates select="(.//email|address/otheraddr/ulink)[1]"/>
+      <xsl:apply-templates select="(.//email|address/otheraddr/ulink)[1]"
+                           mode="metadata.author"/>
     </xsl:if>
   </xsl:template>
 
+  <xsl:template match="email|address/otheraddr/ulink" mode="metadata.author">
+    <xsl:text>&lt;</xsl:text>
+    <xsl:choose>
+      <xsl:when test="self::email">
+        <xsl:variable name="contents">
+          <xsl:apply-templates/>
+        </xsl:variable>
+        <xsl:value-of select="normalize-space($contents)"/>
+      </xsl:when>
+      <xsl:when test="self::ulink">
+        <xsl:variable name="contents">
+          <xsl:apply-templates select="."/>
+        </xsl:variable>
+        <xsl:value-of select="normalize-space($contents)"/>
+      </xsl:when>
+    </xsl:choose>
+    <xsl:text>&gt;</xsl:text>
+  </xsl:template>
+
   <xsl:template match="corpauthor|corpcredit|orgname|publishername" mode="metadata.author">
     <xsl:variable name="contents">
       <xsl:apply-templates/>
index 65e5babe30250efbad01d7a6cbc2080ee779702e..659c6c659ae28fa42c3f4a73a68e08e123e6d2bd 100644 (file)
 
   <!-- ================================================================== -->
 
+  <!-- * The person.name template in the HTML stylesheets outputs extra -->
+  <!-- * spaces that we need to strip out for manpages output. This -->
+  <!-- * template calls person.name, then tries to do some smart -->
+  <!-- * normalization of the result tree fragment from that. -->
   <xsl:template name="person.name.normalized">
     <xsl:variable name="contents">
       <xsl:call-template name="person.name"/>
     </xsl:variable>
-    <xsl:value-of select="normalize-space($contents)"/>
+    <!-- * We put the output of person.name into a node-set and then we -->
+    <!-- * check it node-by-node and strip out space only where needed. -->
+    <xsl:variable name="contents.tree" select="exsl:node-set($contents)"/>
+    <xsl:for-each select="$contents.tree/node()">
+      <xsl:choose>
+        <!-- * We don't want to monkey with single spaces or commas/periods -->
+        <!-- * followed by spaces, because those are bits of text that are -->
+        <!-- * actually generated by the person.name template itself (that -->
+        <!-- * is, they're not in the source. So, we preserve them. -->
+        <xsl:when test=". = ' ' or . = ', ' or . = '. '">
+          <xsl:value-of select="."/>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:value-of select="normalize-space(.)"/>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:for-each>
   </xsl:template>
 
   <!-- ================================================================== -->