]> granicus.if.org Git - docbook-dsssl/commitdiff
Support context info
authorNorman Walsh <ndw@nwalsh.com>
Mon, 2 Apr 2001 11:03:00 +0000 (11:03 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Mon, 2 Apr 2001 11:03:00 +0000 (11:03 +0000)
gentext/xsl/xsl.xsl

index cbd7b7f0277cfa4195662945ecd94aceec561a9d..59e80a4985b500aa400820a23dca9b8eb8608cea 100644 (file)
   </saxon:output>
 </xsl:template>
 
-<xsl:template match="gentext|dingbat|xref">
+<xsl:template match="gentext|dingbat|context">
   <xsl:element name="{name(.)}">
     <xsl:copy-of select="@*"/>
     <xsl:apply-templates/>
   </xsl:element>
 </xsl:template>
 
+<xsl:template match="template">
+  <template>
+    <xsl:copy-of select="@*"/>
+    <xsl:attribute name="text">
+      <xsl:apply-templates select="node()" mode="template-text"/>
+    </xsl:attribute>
+  </template>
+</xsl:template>
+
+<!-- ============================================================ -->
+
+<xsl:template match="*" mode="template-text">
+  <xsl:variable name="key" select="local-name(.)"/>
+  <xsl:variable name="gentext" select="ancestor::locale//gentext[@key=$key]"/>
+
+  <xsl:if test="count($gentext) = 0">
+    <xsl:message terminate="yes">
+      <xsl:text>There is no gentext key '</xsl:text>
+      <xsl:value-of select="$key"/>
+      <xsl:text>' in the '</xsl:text>
+      <xsl:value-of select="ancestor::locale/@language"/>
+      <xsl:text>' locale.</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <xsl:if test="count($gentext) &gt; 1">
+    <xsl:message>
+      <xsl:text>There is more than one gentext key '</xsl:text>
+      <xsl:value-of select="$key"/>
+      <xsl:text>' in the '</xsl:text>
+      <xsl:value-of select="ancestor::locale/@language"/>
+      <xsl:text>' locale.</xsl:text>
+    </xsl:message>
+  </xsl:if>
+
+  <xsl:value-of select="$gentext[1]/@text"/>
+</xsl:template>
+
+<xsl:template match="text()" mode="template-text">
+  <xsl:value-of select="."/>
+</xsl:template>
+
+<!-- ============================================================ -->
+
 </xsl:stylesheet>