]> granicus.if.org Git - docbook-dsssl/commitdiff
HTML sensitive characters are manually escaped in attribute values (we must do it...
authorJirka Kosek <jirka@kosek.cz>
Tue, 15 Oct 2002 14:56:03 +0000 (14:56 +0000)
committerJirka Kosek <jirka@kosek.cz>
Tue, 15 Oct 2002 14:56:03 +0000 (14:56 +0000)
xsl/htmlhelp/htmlhelp-common.xsl

index 4eea43c2fcd3c886f80c22a807f06446744f4648..f976619da96294610d1b45d35026ba2720e7a7c2 100644 (file)
@@ -461,7 +461,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0">
@@ -508,7 +512,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -546,7 +554,7 @@ Title=</xsl:text>
   </xsl:if>
 </xsl:template>
 
-<xsl:template match="part|reference|preface|chapter|bibliography|appendix|article|colophon|glossary"
+<xsl:template match="part|reference|preface|chapter|bibliography|appendix|article|glossary"
               mode="hhc">
   <xsl:variable name="title">
     <xsl:if test="$htmlhelp.autolabel=1">
@@ -557,7 +565,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -589,7 +601,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -619,7 +635,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -650,7 +670,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -681,7 +705,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -712,7 +740,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -743,7 +775,11 @@ Title=</xsl:text>
         <xsl:value-of select="concat($label.markup,$autotoc.label.separator)"/>
       </xsl:if>
     </xsl:if>
-    <xsl:apply-templates select="." mode="title.markup"/>
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value">
+        <xsl:apply-templates select="." mode="title.markup"/>
+      </xsl:with-param>
+    </xsl:call-template>
   </xsl:variable>
 
   <xsl:if test="$htmlhelp.hhc.show.root != 0 or parent::*">
@@ -894,15 +930,25 @@ Title=</xsl:text>
 <xsl:template name="write.indexterm.hhk">
   <xsl:param name="text"/>
   <xsl:param name="seealso"/>
+  <xsl:variable name="text.escaped">
+    <xsl:call-template name="escape-attr">
+      <xsl:with-param name="value" select="$text"/>
+    </xsl:call-template>
+  </xsl:variable>
+
   <![CDATA[<LI> <OBJECT type="text/sitemap">
-        <param name="Name" value="]]><xsl:value-of select="$text"/><xsl:text><![CDATA[">]]></xsl:text>
+        <param name="Name" value="]]><xsl:value-of select="$text.escaped"/><xsl:text><![CDATA[">]]></xsl:text>
       <xsl:if test="not(seealso)">
         <xsl:variable name="href">
           <xsl:call-template name="href.target.with.base.dir"/>
         </xsl:variable>
         <xsl:variable name="title">
-          <xsl:call-template name="nearest.title">
-            <xsl:with-param name="object" select=".."/>
+          <xsl:call-template name="escape-attr">
+            <xsl:with-param name="value">
+              <xsl:call-template name="nearest.title">
+                <xsl:with-param name="object" select=".."/>
+              </xsl:call-template>
+            </xsl:with-param>
           </xsl:call-template>
         </xsl:variable>
         <![CDATA[<param name="Name" value="]]><xsl:value-of select="$title"/><![CDATA[">]]>
@@ -1050,4 +1096,40 @@ Title=</xsl:text>
     <xsl:value-of select="document('')//h:hex/d[$digit+1]"/>
   </xsl:template>
 
+<!-- ==================================================================== -->
+<!-- Template for escaping <, & and " in attribute values. 
+     We aren't using HTML output method, so we must do this job ourselves -->
+
+<xsl:template name="escape-attr">
+  <xsl:param name="value"/>
+
+  <xsl:variable name="amp.escaped">
+    <xsl:call-template name="string.subst">
+      <xsl:with-param name="string" select="$value"/>
+      <xsl:with-param name="target" select="'&amp;'"/>
+      <xsl:with-param name="replacement" select="'&amp;amp;'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="quot.escaped">
+    <xsl:call-template name="string.subst">
+      <xsl:with-param name="string" select="$amp.escaped"/>
+      <xsl:with-param name="target" select="'&quot;'"/>
+      <xsl:with-param name="replacement" select="'&amp;quot;'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:variable name="angle.escaped">
+    <xsl:call-template name="string.subst">
+      <xsl:with-param name="string" select="$quot.escaped"/>
+      <xsl:with-param name="target" select="'&lt;'"/>
+      <xsl:with-param name="replacement" select="'&amp;lt;'"/>
+    </xsl:call-template>
+  </xsl:variable>
+
+  <xsl:value-of select="$angle.escaped"/>
+
+</xsl:template>
+  
+
 </xsl:stylesheet>