]> granicus.if.org Git - docbook-dsssl/commitdiff
Added evaluate.info.profile template.
authorMichael Smith <xmldoc@users.sourceforge.net>
Tue, 5 Jul 2005 00:54:57 +0000 (00:54 +0000)
committerMichael Smith <xmldoc@users.sourceforge.net>
Tue, 5 Jul 2005 00:54:57 +0000 (00:54 +0000)
xsl/common/common.xsl

index 4d2be1860c12e001cab87496eecb76c46b7ee67e..73bcb98694d04277427b66ae99fd5085e21f615d 100644 (file)
@@ -1,7 +1,9 @@
 <?xml version='1.0'?>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
-                exclude-result-prefixes="doc"
+                xmlns:dyn="http://exslt.org/dynamic"
+                xmlns:saxon="http://icl.com/saxon"
+                exclude-result-prefixes="doc dyn saxon"
                 version='1.0'>
 
 <!-- ********************************************************************
@@ -1876,4 +1878,77 @@ unchanged.</para>
   </xsl:choose>
 </xsl:template>
 
+<!-- ===================================== -->
+
+<doc:template name="evaluate.info.profile" xmlns="">
+  <refpurpose>Evaluates an info profile</refpurpose>
+  <refdescription>
+    <para>This function evaluates an "info profile" matching the XPath
+    expression given by the <parameter>profile</parameter>
+    parameter. It relies on the XSLT <function>evaluate()</function>
+    extension function.</para>
+
+    <para>The value of the <parameter>profile</parameter> parameter
+    can include the strings <literal>$info</literal> and
+    <literal>$parentinfo</literal>. If found in the value of the
+    <parameter>profile</parameter> parameter, those strings are
+    evaluated using the <parameter>info</parameter> and
+    <parameter>parentinfo</parameter> parameters, the values of which
+    should be DocBook <replaceable>*info</replaceable> element node
+    sets.</para>
+  </refdescription>
+  <refparameter>
+    <variablelist>
+       <varlistentry>
+        <term>profile</term>
+        <listitem>
+          <para>A string representing an XPath expression </para>
+        </listitem>
+      </varlistentry>
+       <varlistentry>
+        <term>info</term>
+        <listitem>
+          <para>A DocBook info node</para>
+        </listitem>
+      </varlistentry>
+      <varlistentry>
+        <term>parentinfo</term>
+        <listitem>
+          <para>A DocBook info node (from a parent element)</para>
+        </listitem>
+      </varlistentry>
+    </variablelist>
+  </refparameter>
+
+  <refreturn>
+    <para>Returns a node (the result of evaluating the
+    <parameter>profile</parameter> parameter)</para>
+  </refreturn>
+</doc:template>
+
+  <xsl:template name="evaluate.info.profile">
+    <xsl:param name="profile"/>
+    <xsl:param name="info"/>
+    <xsl:param name="parentinfo"/>
+    <xsl:choose>
+      <!-- xsltproc and Xalan both support dyn:evaluate() -->
+      <xsl:when test="function-available('dyn:evaluate')">
+        <xsl:apply-templates
+            select="dyn:evaluate($profile)"/>
+      </xsl:when>
+      <!-- Saxon has its own evaluate() & doesn't support dyn:evaluate() -->
+      <xsl:when test="function-available('saxon:evaluate')">
+        <xsl:apply-templates
+            select="saxon:evaluate($profile)"/>
+      </xsl:when>
+      <xsl:otherwise>
+        <xsl:message terminate="yes">
+Error: The "info profiling" mechanism currently requires an XSLT
+engine that supports the evaluate() XSLT extension function. Your XSLT
+engine does not support it.
+</xsl:message>
+      </xsl:otherwise>
+    </xsl:choose>
+  </xsl:template>
+
 </xsl:stylesheet>