diff summa/bilingual/bi.xsl @ 72:3dd981256764

fix summa links
author ht
date Sun, 03 Jan 2010 23:43:20 +0000
parents 52063d0f8985
children e45e864fda83
line wrap: on
line diff
--- a/summa/bilingual/bi.xsl	Sun Jan 03 18:56:45 2010 +0000
+++ b/summa/bilingual/bi.xsl	Sun Jan 03 23:43:20 2010 +0000
@@ -1,8 +1,24 @@
 <?xml version='1.0'?>
 <!DOCTYPE xsl:stylesheet SYSTEM "../../../../lib/xml/xsl.dtd" >
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:x="http://www.w3.org/1999/xhtml">
+ <xsl:param name="rawpart"/>
+ <xsl:variable name="part" select="concat(substring-before($rawpart,'.'),'_',substring-after($rawpart,'.'),'.html')"/>
+ <xsl:variable name="index" select="document('../english/index.xml',/)/*"/>
+ <xsl:key name="iq" match="file" use="substring-before(@name,'_')"/>
  
- <xsl:template match="x:a[@href and not(text())]"/>
+ <xsl:template match="x:a[starts-with(@href,'summa.')]">
+  <xsl:variable name="tw" select="substring-before(substring-after(@href,'summa.'),'.')"/>
+  <xsl:variable name="tp" select="substring-before($tw,'_')"/>
+  <xsl:variable name="ta" select="substring-after($tw,'_A')"/>
+  <xsl:variable name="tq" select="number(substring-after(if ($ta='') then $tw else substring-before($tw,'_A'),'_Q'))"/>
+  <xsl:variable name="ff" select="key('iq',$tp,$index)"/>
+  <xsl:variable name="f" select="$ff[number(@first) le $tq][number(@last) ge $tq]/@name"/>
+  <xsl:message>ref: <xsl:value-of select="$tw"/><xsl:text> </xsl:text><xsl:value-of select="$f"/></xsl:message>
+  <xsl:copy>
+   <xsl:attribute name="href"><xsl:value-of select="concat(if ($part=$f) then '' else (if ($f) then $f else 'unknown.html'),'#',$tw)"/></xsl:attribute>
+   <xsl:apply-templates select="@*[not(local-name()='href')]|node()"/>
+  </xsl:copy>
+ </xsl:template>
  
  <xsl:template match="x:h3">
   <xsl:copy>