Hendrik Human
Hendrik Human

Reputation: 135

Add image to pdf through xsl-fo using XML attribute value

I'm making a PDF from an XMl doc using XSL-FO. I need to import images using their names that are inside the XML doc.

Example XML:

<newAlbums>
   <album cover="blaimage.jpg"/>
</newAlbums>

I need to do this through a similar statement:

<fo:external-graphic src="({})/>

What XPath do I need to put inside the src attribute to import the image? Thanks for the help this has been killing me.

Upvotes: 3

Views: 4132

Answers (1)

Dabbler
Dabbler

Reputation: 9873

It will basically be <fo:external-graphic src="{concat('url(', /newAlbums/album/@cover, ')')}">. The exact XPath expression will depend on your XML. For example, you will most likely have more than one album element, so /newAlbums/album[1]/@cover or similar will be required.

Upvotes: 9

Related Questions