2010-10-01 4 views
2

Je souhaite créer un fichier xsl (pour une transformation xslt en xsl: fo en utilisant un xml) Comment afficher une image dont l'URL est stockée dans le fichier xml? Je peux utiliser des variablesDéfinition dynamique d'une URL d'image dans un fichier xsl

<fo:block-container top="5mm" height="20mm" left="0mm" width="75mm"> 
     <fo:block margin-top="10mm" margin-left="50mm"> 
     <fo:external-graphic display-align="center" src="url('{$imageUrl}')" content-width="75mm"></fo:external-graphic> 
     </fo:block> 
    </fo:block-container> 

Mais comment puis-je définir la valeur de la variable d'une étiquette à partir du fichier xml?

XML Exemple de commentaire:

<?xml version="1.0" encoding="UTF-8" ?> 
<doc> 
    <title>Simple test</title> 
    <image> 
    <i>colour_logo.jpg</i> 
    </image> 
    <body> 
    <question> 
     <p>Is the sky blue?</p> 
    </question> 
    <question> 
     <p>Is the grass blue?</p> 
    </question> 
    </body> 
</doc> 
+0

L'échantillon XML serait utile. Vous pouvez obtenir l'URL/le chemin de l'image à partir du XML en utilisant XPATH dans votre XSLT, mais sans aucun exemple XML il est difficile de vous donner un XPath –

+0

- Test simple - de colour_logo.jpg - -

est le bleu du ciel?

-

L'herbe est-elle bleue?

Lullaby

Répondre

3

Vous pouvez remplacer {$imageUrl} avec {/doc/image/i}.

<fo:block-container top="5mm" height="20mm" left="0mm" width="75mm"> 
    <fo:block margin-top="10mm" margin-left="50mm"> 
     <fo:external-graphic display-align="center" src="url('{/doc/image/i}')" content-width="75mm"></fo:external-graphic> 
    </fo:block> 
    </fo:block-container>