Forum Moderators: open
Basically I have a template which goes as follows:
<images>
<image>
<id>001</id>
<name>Image 1</name>
<caption>Some text describing this image</caption>
<url color={$WhichColor}>image1.png</url>
</image>
</images>
Now, in my XSL document I wanted a global variable that will set up the root for all images in my site.
<xsl:variable name="Root" select="images/" />
Then I wanted a variable which will pic up the root for all images in that section of the site:
<xsl:variable name="MyImages" select="colorschemes/" />
Finally I wanted another variable which will select a particular color for this page of the site
<xsl:variable name="WhichColor" select="" />
I would like to set up this last variable to nothing so that for each page I could write something along the lines of "red/myimagename.png", "blue/myimagename.png" etc.
All images have the same name, the only thing that is different about them is the color directory.
Then I need to somehow pass this together with my image name as an alt tag into the <img> tag.
I was thinking of something like:
<xsl:template match="images/">
<xsl:for-each select="image">
<img src="{$Root}{$MyImages}<xsl:value-of select="WhichColor" /><xsl:value-of select="url" />" alt="<xsl:value-of select="url" />">
</xsl:for-each>
</xsl:template>
I don't know much about the XML syntax and this is obviourly very wrong, how do I output that into an image tag with a flexible WhichColor variable output?
I hope that I have explained myself correctly this time!
Thank you!
Just as an observation, you have some invalid syntax (e.g. {$WhichColor} must be quoted, and XPath cannot end with a trailing slash), so a good XPath reference may be in order.