Autogenerate search.php from the html templates
[senf.git] / doclib / html-munge.xsl
index e1cc7d6..d025ef6 100644 (file)
@@ -6,23 +6,49 @@
     encoding="html" \r
     doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"\r
     doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>\r
+\r
+  <xsl:param name="topdir" select="''"/>\r
   \r
   <xsl:template match="*">\r
     <xsl:copy>\r
-      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>\r
+      <xsl:call-template name="copy-attributes"/>\r
       <xsl:apply-templates/>\r
     </xsl:copy>\r
   </xsl:template>\r
   \r
+  <xsl:template name="copy-attributes">\r
+    <xsl:for-each select="@*">\r
+      <xsl:attribute name="{name(current())}">\r
+        <xsl:choose>\r
+          <xsl:when test="contains(current(),'@TOPDIR@')">\r
+            <xsl:value-of select="substring-before(current(),'@TOPDIR@')"/>\r
+            <xsl:value-of select="$topdir"/>\r
+            <xsl:value-of select="substring-after(current(),'@TOPDIR@')"/>\r
+          </xsl:when>\r
+          <xsl:otherwise>\r
+            <xsl:value-of select="current()"/>\r
+          </xsl:otherwise>\r
+        </xsl:choose>\r
+      </xsl:attribute>\r
+    </xsl:for-each>\r
+  </xsl:template>\r
+  \r
   <xsl:template match="li[form]"> \r
   </xsl:template>\r
   \r
+  <!-- Replace @TOPDIR@ with  relative top directory path -->\r
+  <xsl:template match="@*[contains(current(),'@TOPDIR@')]">\r
+    <xsl:value-of select="substring-before(current(),'@TOPDIR')"/>\r
+    <xsl:value-of select="$topdir"/>\r
+    <xsl:value-of select="substring-after(current(),'@TOPDIR')"/>\r
+  </xsl:template>\r
+  \r
   <!-- Add 'class' attribute to some special paragraphs/lists -->\r
   \r
   <xsl:template name="add-class">\r
     <xsl:param name="class"/>\r
     <xsl:copy>\r
-      <xsl:for-each select="@*"><xsl:copy/></xsl:for-each>\r
+      <xsl:call-template name="copy-attributes"/>\r
       <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>\r
       <xsl:apply-templates/>\r
     </xsl:copy>\r