Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Images in XSL from XML file

The goal in mind is to create a dynamic catalogue page for a class project.
I have an XML page being generated from an SQL query using JSP. One of the
fields in the database holds the picture file locations as a string, since
Oracle makes using images directly somewhat tricky. I'm trying to figure
out how to get the value of the xml tag into a <img src> tag on the XSL page.
Is this even possible?

The simplest and most obvious solution was try putting the complete <xsl:value-of
select="Picture"/> inside the <img src=" "> tag, but it comes back with a
namespace error and refuses to run any further.

Most solutions I've been able to find involve complex javascripting to play
with pictures directly, I simply want to make a string variable available
when and where I need it so XSL's ability to use straight HTML tags will
let me display it where I need it.

Any suggestions? Even ones that make it clear I'm a complete twit?
[1033 byte] By [CDM] at [2007-11-9 16:16:50]
# 1 Re: Images in XSL from XML file
I didn't test this, but it should be close.

<img>
<xsl:attribute name="src"><xsl:value-of select
="Picture"/></xsl:attribute>
</img>

"CDM" <digbat235@hotmail.com> wrote in message
news:3e70e335$1@tnews.web.dev-archive.com...
>
> The goal in mind is to create a dynamic catalogue page for a class
project.
> I have an XML page being generated from an SQL query using JSP. One of the
> fields in the database holds the picture file locations as a string, since
> Oracle makes using images directly somewhat tricky. I'm trying to figure
> out how to get the value of the xml tag into a <img src> tag on the XSL
page.
> Is this even possible?
>
> The simplest and most obvious solution was try putting the complete
<xsl:value-of
> select="Picture"/> inside the <img src=" "> tag, but it comes back with a
> namespace error and refuses to run any further.
>
> Most solutions I've been able to find involve complex javascripting to
play
> with pictures directly, I simply want to make a string variable available
> when and where I need it so XSL's ability to use straight HTML tags will
> let me display it where I need it.
>
> Any suggestions? Even ones that make it clear I'm a complete twit?
Russell Jones at 2007-11-11 23:36:16 >
# 2 Re: Images in XSL from XML file
Thanks a lot, I looks like it works.

"Russell Jones" <arj1@nospam.northstate.net> wrote:
>I didn't test this, but it should be close.
>
><img>
> <xsl:attribute name="src"><xsl:value-of select
>="Picture"/></xsl:attribute>
></img>
CDM at 2007-11-11 23:37:22 >
# 3 Re: Images in XSL from XML file
Opps, spoke too soon.

It puts up a broken image link box, on IE it shows up as a small box with
a red X in the middle. But I can't seem to get it to go any further. I've
even tried changing the database outputs to full URL references without any
success. I suspect I'm missing something relatively fundamental here.

I've tried running it directly via editplus and through the apache server
on this machine. Both normally have full access to the college LAN and from
there to the internet.
CDM at 2007-11-11 23:38:21 >
# 4 Re: Images in XSL from XML file
Apparently, the browser recognizes that you created an image tag, (the box
with the red X signifies a missing image) but it can't get the image from
the server. Probably because the path to the image is incomplete. Here's how
to test. When you look at the html source, did your code create a valid
<img> tag? In other words, if you copy the created image tag and test it in
a simple HTML file, does it work? If not, experiment with the simple HTML
<img> tag until you get it to work, and then make your code output the same
thing.

"CDM" <digbat235@hotmail.com> wrote in message
news:3e724a6d$1@tnews.web.dev-archive.com...
>
> Opps, spoke too soon.
>
> It puts up a broken image link box, on IE it shows up as a small box with
> a red X in the middle. But I can't seem to get it to go any further. I've
> even tried changing the database outputs to full URL references without
any
> success. I suspect I'm missing something relatively fundamental here.
>
> I've tried running it directly via editplus and through the apache server
> on this machine. Both normally have full access to the college LAN and
from
> there to the internet.
Russell Jones at 2007-11-11 23:39:20 >