Search code examples
xmlimagexsltapache-fop

Load Image from XML to XSLT using FOP Apache


I am trying to load an image from my XML to my XSLT.
I am using XML 1.0.
I found a lot of solutions, but my XML has another construction, so I hope someone is able to help.

This is my XML:

<groundplan>
    <drawing mime_type="image/png" url="./Pictures/drawing1.png"></drawing>
    <drawing mime_type="image/png" url="./Pictures/drawing2.png"></drawing>
</groundplan>

XSLT:

<?xml version="1.0" encoding="ISO-8859-1"?>    
<fo:table-row>
    <fo:table-cell>
        <fo:block>                
            <fo:external-graphic content-height="33mm" content-width="190mm" scaling="non-uniform" src=""/>
        </fo:block>
    </fo:table-cell>        
</fo:table-row>

<fo:table-row>
    <fo:table-cell>
        <fo:block>                
            <fo:external-graphic content-height="33mm" content-width="190mm" scaling="non-uniform" src=""/>
        </fo:block>
    </fo:table-cell>        
</fo:table-row>

Is it possible to add the source from my XML?

Thx for all the help!


Solution

  • Just match each drawing:

    <xsl:template match="/groundplan/drawing">
       <fo:table-row>
         <fo:table-cell>
            <fo:block>                
                <fo:external-graphic content-height="33mm" content-width="190mm" scaling="non-uniform" src="{@url}"/>
            </fo:block>
         </fo:table-cell>        
       </fo:table-row>
    </xsl:template>