]> granicus.if.org Git - docbook-dsssl/commitdiff
Implemented feature request #1072510 as a processing instruction
authorBob Stayton <bobs@sagehill.net>
Sun, 7 May 2006 02:22:41 +0000 (02:22 +0000)
committerBob Stayton <bobs@sagehill.net>
Sun, 7 May 2006 02:22:41 +0000 (02:22 +0000)
to permit including external HTML content into HTML output.

xsl/html/pi.xsl

index 064138c03bd4e44c6242539d04da2c9210e75023..03a7d6faca7654bf5d1fc97a84366b2b9a854958 100644 (file)
 
 <!-- ==================================================================== -->
 
+<!-- Copy well-formed external HTML content to the output. -->
+<!-- An optional <html> wrapper will be removed before content is copied 
+     to support multiple elements in output without a wrapper.
+     No other processing is done to the content. -->
+<xsl:template match="processing-instruction('dbhtml-include')">
+  <xsl:param name="href">
+    <xsl:call-template name="dbhtml-attribute">
+      <xsl:with-param name="pis" select="."/>
+      <xsl:with-param name="attribute">href</xsl:with-param>
+    </xsl:call-template>
+  </xsl:param>
+
+  <xsl:choose>
+    <xsl:when test="$href != ''">
+      <xsl:variable name="content" select="document($href,/)"/>
+      <xsl:choose>
+        <xsl:when test="$content/*">
+          <xsl:choose>
+            <xsl:when test="$content/*[1][self::html]">
+              <!-- include just the children of html wrapper -->
+              <xsl:copy-of select="$content/*[1]/node()"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:copy-of select="$content"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </xsl:when>
+        <xsl:otherwise>
+          <xsl:message>
+            <xsl:text>ERROR: dbhtml-include processing instruction </xsl:text>
+            <xsl:text>href has no content.</xsl:text>
+          </xsl:message>
+        </xsl:otherwise>
+      </xsl:choose>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:message>
+        <xsl:text>ERROR: dbhtml-include processing instruction has </xsl:text>
+        <xsl:text>missing or empty href value.</xsl:text>
+      </xsl:message>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 </xsl:stylesheet>