Re: [docbook-apps] Image callouts and roles

From
Bob Stayton <>
Date
2011-10-03T13:22:15+00:00
ID
099901cc81cf$62b69cd0$6400a8c0@pazu
Thread
Re: [docbook-apps] Image callouts and roles


Indeed.  Here is the update to the template 
for the imageobjectco element I was going to check in.  It should work 
equally well in an html or fo customization layer. It uses the same 
mechanism to select a role attribute.  The difference from mediaobject 
is that it only does the selection if the right conditions are met, on the 
assumption that you may intend to have multiple imageobjects in your 
output.   Let me know if it works for you.

 

<xsl:template 
match="imageobjectco">

 

  <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>

Bob Stayton
Sagehill Enterprises


 

 

  
----- Original Message ----- 

  
From: 
  Chris Ridd 
  

  
To: Bob Stayton 

  
Cc:  
  

  
Sent: Monday, October 03, 2011 5:43 
  AM

  
Subject: Re: [docbook-apps] Image 
  callouts and roles

  

  

  

On 03 Oct, 2011,at 11:37 AM, Bob Stayton <> wrote:

  

  
    
 
    
Hi  
    Chris,

    
OK.  Prior to 
    Docbook 5, imageobjectco only allowed one imageobject, so that is the case 
    that the stylesheet currently handles.  I did not realize that 
    more  than one was allowed in DocBook 5, so that will need  to get 
    fixed in the stylesheets. I filed a bug report.

    

  
Thanks; sorry for messing up the original test case. 
  

  

  

  
    

    
For now, the selection 
    process applies only to the direct children of mediaobject.  That's why 
    you are getting both images in your output.  You'll need to create two 
    children of mediaobject for the selection to 
  work.

  

  
Indeed that works (rendering one image) but I think it leaves me with a 
  different problem :-)

  

  
The reason I'm using an imageobjectco is because after the (in this case) 
  'screenshot' element I've got a calloutlist which has callout elements 
  referencing various areas on the imageobjectco.

  

  
Now if I'm using multiple 'imageobjectco' elements, each would have a 
  separate 'areaspec', and each 'areaspec' would have a separate list of 
  'area's. Because the 'callout' has to reference the area by its xml:id, this 
  looks to me like I'd need to create two 'area' elements with the same xml:id. 
  Not good!

  

  
If I create areas with different xml:ids, I can use <callout 
  arearefs="fo-id1 html-id1"><para>text</para></callout> in 
  my calloutlist, however that gets rendered as "(1)(1) text". eg

  

  
    <screenshot>
      
  <mediaobject>
        
  <imageobjectco 
  role="fo">
          
  <areaspec>
            
  <area coords="500,500,600,600" 
  xml:id="fo-id1"/>
          
  </areaspec>
          
  <imageobject>
            
  <imagedata 
  fileref="/path/to/fo.png"/>
          
  </imageobject>
        
  </imageobjectco>
        
  <imageobjectco 
  role="html">
          
  <areaspec>
            
  <area coords="500,500,600,600" 
  xml:id="html-id1"/>
          
  </areaspec>
          
  <imageobject>
            
  <imagedata 
  fileref="/path/to/html.png"/>
          
  </imageobject>
        
  </imageobjectco>
      
  </mediaobject>
    
  </screenshot>
    
  <calloutlist>
      <callout 
  arearefs="fo-id1 html-id1">
        
  <para>text</para>
      
  </callout>
    </calloutlist>

  
(Both variants there are using PNGs, just for simplicity. In reality one 
  would be an SVG and the other would be PNG.)

  

  
Cheers,

  

  
Chris