Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

showing dynamic images with xml/xsl

 
Icebeer icebeer
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i've got some xml file like this:
<list>
<image>image1.gif</image>
.
.
.
</list>
i know, i have to use Javascript to display this images in a XSL file like
function ShowImage(pic, name) {
document.write ('<img src="images/' + pic + '" name="' + name + '" border="0">');
}
but this gets very annoying when it comes to "onMouseOver change the pic" pics and similar things (e.g. links, ...)
is there an easier way to solve this or do i have to stick to the JS way?
thanks for any advice,
Thomas
 
Mapraputa Is
Leverager of our synergies
Sheriff
Posts: 10065
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Three is absolutely no need for JavaScript. You can output img tag with XSLT:
in your stylesheet:
<img src="{concat ('images/', list/image)}" onMouseOver="changeThePic()"/>
output:
<img onMouseOver="changeThePic()" src="images/image1.gif">
Put an XPath expression to access proper image instead of list/image. For example, if you have
<list>
<image>image1.gif</image>
<image>image2.gif</image>
</list>
and you want to access the second image, it will be "list/image[2]"
Also, you name doesn't comply with JavaRanch Official policy on registered names . Please, re-register following "FirstName LastName" pattern!
 
Thomas K
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THX! i'm quite new to this so sorry for the feeble question
changed my name BTW, was in a hurry the last time.
nice board, skilled answers, i'm impressed.
cya
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your name "Thomas K" still does not comply with the JavaRanch naming policy. Note that your last name should be atleast two characters long.
Please spare a moment and re-register with a name that meets the requirements.
Thank you!
 
Thomas Kol
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
better?
 
Ajith Kallambella
Sheriff
Posts: 5782
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic