]> granicus.if.org Git - docbook-dsssl/commitdiff
Allow selection by role for multiple imageobject elements
authorBob Stayton <bobs@sagehill.net>
Mon, 3 Oct 2011 15:51:48 +0000 (15:51 +0000)
committerBob Stayton <bobs@sagehill.net>
Mon, 3 Oct 2011 15:51:48 +0000 (15:51 +0000)
within an imageobjectco, which since Docbook 5 allows multiple imageobjects.

xsl/fo/graphics.xsl
xsl/html/graphics.xsl

index 1154f8483db5bfc41b3534ca521a8ea89b07e140..151acd27c1363cb0edb1e64371daf3d3475c10e6 100644 (file)
 <!-- ==================================================================== -->
 
 <xsl:template match="imageobjectco">
-  <xsl:apply-templates select="imageobject"/>
+  <xsl:choose>
+    <!-- select one imageobject? -->
+    <xsl:when test="$use.role.for.mediaobject != 0 and
+                    count(imageobject) &gt; 1 and
+                    imageobject[@role]">
+      <xsl:variable name="olist" select="imageobject"/>
+    
+      <xsl:variable name="object.index">
+        <xsl:call-template name="select.mediaobject.index">
+          <xsl:with-param name="olist" select="$olist"/>
+          <xsl:with-param name="count" select="1"/>
+        </xsl:call-template>
+      </xsl:variable>
+    
+      <xsl:variable name="object" select="$olist[position() = $object.index]"/>
+    
+      <xsl:apply-templates select="$object"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <!-- otherwise process them all -->
+      <xsl:apply-templates select="imageobject"/>
+    </xsl:otherwise>
+  </xsl:choose>
+
   <xsl:apply-templates select="calloutlist"/>
+
 </xsl:template>
 
 <xsl:template match="imageobject">
index ac0550f48204bdff622e3c9cf0d51f3ca6fb4c7d..b9df7a82f73af7cc39414a7d9e14aafd99bfb309 100644 (file)
@@ -1159,8 +1159,32 @@ valign: <xsl:value-of select="@valign"/></xsl:message>
 
 <xsl:template match="imageobjectco">
   <xsl:call-template name="anchor"/>
-  <xsl:apply-templates select="imageobject"/>
+  <xsl:choose>
+    <!-- select one imageobject? -->
+    <xsl:when test="$use.role.for.mediaobject != 0 and
+                    count(imageobject) &gt; 1 and
+                    imageobject[@role]">
+      <xsl:variable name="olist" select="imageobject"/>
+    
+      <xsl:variable name="object.index">
+        <xsl:call-template name="select.mediaobject.index">
+          <xsl:with-param name="olist" select="$olist"/>
+          <xsl:with-param name="count" select="1"/>
+        </xsl:call-template>
+      </xsl:variable>
+    
+      <xsl:variable name="object" select="$olist[position() = $object.index]"/>
+    
+      <xsl:apply-templates select="$object"/>
+    </xsl:when>
+    <xsl:otherwise>
+      <!-- otherwise process them all -->
+      <xsl:apply-templates select="imageobject"/>
+    </xsl:otherwise>
+  </xsl:choose>
+
   <xsl:apply-templates select="calloutlist"/>
+
 </xsl:template>
 
 <xsl:template match="imageobject">