Need to show two different alt text for images in PDF file?
<p>I am parsing an XML data through XSL-FO template and finally generating a PDF file to display the images to show two different alt text for those images. Based on the flag on XML file, I am choosing an alt-text to show it on PDF.</p>

<p>My XML:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;?xml-stylesheet type="text/xsl" href="test.xsl"?&gt;
&lt;list&gt;
    &lt;details&gt;
        &lt;name&gt;Test123&lt;/name&gt;
        &lt;age&gt;22&lt;/age&gt;
        &lt;isDuck&gt;true&lt;/isDuck&gt;
        &lt;images&gt;http://www.freedigitalphotos.net/images/img/homepage/87357.jpg&lt;/images&gt;
    &lt;/details&gt;
    &lt;details&gt;
        &lt;name&gt;Test123&lt;/name&gt;
        &lt;age&gt;22&lt;/age&gt;
        &lt;isDog&gt;true&lt;/isDog&gt;
        &lt;images&gt;http://www.isharearena.com/wp-content/uploads/2012/12/wallpaper-281049.jpg?d54e04&lt;/images&gt;
    &lt;/details&gt;
    ...
&lt;/list&gt;
</code></pre>

<p>My XSL-FO:</p>

<pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
    &lt;xsl:template match="list"&gt;
        &lt;fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en"
            white-space-treatment="ignore-if-after-linefeed" role="Document" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"&gt;
            &lt;fo:layout-master-set&gt;
                &lt;fo:simple-page-master master-name="testing" page-width="21cm" page-height="29.7cm"&gt;
                    &lt;fo:region-body margin-top="2cm" margin-bottom="2cm" 
                                    margin-left="2cm" margin-right="2cm"/&gt;
                    &lt;fo:region-after region-name="footer" extent="20mm"/&gt;
                &lt;/fo:simple-page-master&gt;
            &lt;/fo:layout-master-set&gt;

            &lt;fo:page-sequence master-reference="testing"&gt;
                &lt;fo:flow flow-name="xsl-region-body"&gt;
                    &lt;xsl:for-each select="./details"&gt;
                        &lt;fo:block&gt;
                            &lt;xsl:choose&gt;
                                &lt;xsl:when test="isDuck = 'true'"&gt;
                                    &lt;fo:external-graphic content-width="scale-to-fit" content-height="scale-to-fit" role="P" width="39.250em" height="23.250em" fox:alt-text="This is Duck"&gt;
                                        &lt;xsl:attribute name="src"&gt;
                                            &lt;xsl:value-of select="images" /&gt;
                                        &lt;/xsl:attribute&gt;
                                    &lt;/fo:external-graphic&gt;
                                &lt;/xsl:when&gt;
                                &lt;xsl:otherwise&gt;
                                    &lt;fo:external-graphic content-width="scale-to-fit" content-height="scale-to-fit" role="P" width="39.250em" height="23.250em" fox:alt-text="This is Dog"&gt;
                                        &lt;xsl:attribute name="src"&gt;
                                            &lt;xsl:value-of select="images" /&gt;
                                        &lt;/xsl:attribute&gt;
                                    &lt;/fo:external-graphic&gt;
                                &lt;/xsl:otherwise&gt;
                            &lt;/xsl:choose&gt;
                        &lt;/fo:block&gt;
                    &lt;/xsl:for-each&gt;
                &lt;/fo:flow&gt;
            &lt;/fo:page-sequence&gt;
        &lt;/fo:root&gt;
    &lt;/xsl:template&gt;
&lt;/xsl:stylesheet&gt;
</code></pre>

<p>I wanted to show the alt-text for first image as <strong>"This is Duck"</strong> and second image as <strong>"This is Dog"</strong>. I am getting an image on PDF but <code>fox:alt-text</code> attribute is not showing an alternative text in PDF file.</p>

<p>Really appreciate your help on this...</p>