Jump to content

Create an <img> element during transformation...


K_Drive

Recommended Posts

I have an XML file with a list of books. The first part of the XML file with one record is at the end of this message.One element in the XML file contains the value that is the name of a bitmap file image. For example:

<ImgName>Decade_Of_The_Wolf.bmp</ImageName>

I am trying to use this value to display the image on an XSLT-generatred webpage.I am trying to generate the following HTML code in order to display the images when I display the list of books:

<img src="Book_Images/Decade_Of_The_Wolf.bmp" />

My first attempt was to do this:

<xsl:text><</xsl:text> <xsl:text>img src="Book_Images/</xsl:text><xsl:value-of select="ImgName" /><xsl:text>" /</xsl:text><xsl:text>></xsl:text>

My second attempt was to do this:

<xsl:value-of select="concat('<', 'img src=', '"', 'Book_Images/')" /><xsl:value-of select="ImgName" /><xsl:value-of select="concat('"', ' ', '/>')" />

Both of these attempts resulted in the correct HTML text for an <img> element appearing on the web page, but the images were not displayed. See the example just below.This is what was displayed on the web page for one of the books:

<img src="Book_Images/Decade_Of_The_Wolf.bmp" />

The correct filenames for each book was retreived properly.The XML element name, "ImgName", is correct.The path to the Book_Image directory is correct.The image name is correct.How can I generate XSL code that will produce the <img> element that will display the images for each book in the XML file instead of just the HTML code as text?--------------------------------------------------------------------------------------------------------------------------------------------------Here is the first part of my XML file:

<BookList>	 <Book>		  <Title PaperOrHard="Hardback">Decade Of The Wolf : Returning The Wild To Yellowstone</Title>		  <Author>			   <FirstName>Douglas</FirstName>			   <MiddleName>W.</MiddleName>			   <LastName>Smith</LastName>		  </Author>		  <Editor>			   <FirstName>John</FirstName>			   <MiddleName>Peter</MiddleName>			   <LastName>Ottoman</LastName>		  </Editor>		  <Publisher>Lyons Press</Publisher>		  <YearPublished>2005</YearPublished>		  <Edition>2nd</Edition>		  <NbrOfPages>212</NbrOfPages>		  <ImgName>Decade_Of_The_Wolf.bmp</ImgName>	 </Book>.........</BookList>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...