OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

docbook-apps message

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]


Subject: Re: [docbook-apps] xslt for imageobject link


Hi,

I figured out that the select.mediaobject was not involved
but the HTML template :
<xsl:template match="d:mediaobject|d:mediaobjectco">

With the below script[1] I get what I want. The variable selection link = object.index+1 is not very nice but works for now.

Just that an extra xmlns:d="http://docbook.org/ns/docbook"; is added.

<div xmlns:d="http://docbook.org/ns/docbook"; class="mediaobject"><img src="./IMG-500.JPG"/> (<a href="IMG.JPG"><span>Original</span></a>)<div class="caption"><p>
This is a picture
</p></div></div>

More tests are needed to find bugs.. :)

Fredrik Unger

[1]
<xsl:template match="d:mediaobject|d:mediaobjectco">

<xsl:variable name="olist" select="d:imageobject|d:imageobjectco |d:videoobject|d:audioobject |d:textobject"/>

  <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:variable name="link" select="$olist[position() = $object.index+1]"/>

  <xsl:variable name="align">
<xsl:value-of select="$object/descendant::d:imagedata[@align][1]/@align"/>
  </xsl:variable>

  <div>
    <xsl:apply-templates select="." mode="common.html.attributes"/>
    <xsl:if test="$align != '' ">
      <xsl:attribute name="align">
        <xsl:value-of select="$align"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:call-template name="id.attribute"/>
    <xsl:call-template name="anchor"/>
    <xsl:apply-templates select="$object"/>
    <xsl:apply-templates select="$link"/>
    <xsl:apply-templates select="d:caption"/>
  </div>
</xsl:template>

<xsl:template match="d:imageobject[@condition='original']">
  <xsl:text> (</xsl:text>
  <xsl:element name="a">
    <xsl:attribute name="href">
      <xsl:value-of select="d:imagedata/@fileref"/>
    </xsl:attribute>
    <span>Original</span>
  </xsl:element>
  <xsl:text>)</xsl:text>
</xsl:template>



On 2014-03-26 19:17, Fredrik Unger wrote:
Hi,

I have the following snippet :
<mediaobject>
   <imageobject>
     <imagedata fileref="IMG-500.JPG"/>
   </imageobject>
   <imageobject condition="original">
     <imagedata fileref="IMG.JPG"/>
   </imageobject>
   <caption>
     <para>
       This is a picture
     </para>
   </caption>
</mediaobject>

I would like to produce this html or some version there of :

..
<img src="IMG-500.JPG" />
<a href="IMG.JPG">Original</a>
<p> This is a picture</p>
..
....


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [List Home]