Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

77 users online



XSL Conflict

XSL Conflict

Currently viewing this thread: 1 (0 members and 1 guests)


Peyton

Peyton

Status: Offline!

XSL Conflict

At the moment, I am using Perl to parse XML data with an XSL stylesheet for a website I am making. However, I have run into a conflict that I need to try and get around.

Basically, I need to use data from an XML file for an attribute for an HTML tag.

For example, take a look at this ( made up ) XML file:

Code:

<?xml version='1.0' encoding='utf-8'?>
<people>
<person>
<name>Bob</name>
<job>Plumber</job>
<picture>bob.jpg</picture>
</person>
<person>
<name>Cookie Monster</name>
<job>Professional Thief</job>
<picture>monster.jpg</picture>
</person>
<person>
<name>Janet</name>
<job>Pencil Salesman</job>
<picture>janetPencil.jpg</picture>
</person>
</people>

Now, here comes the problem. I want to use the value of 'picture' in an image tag. The following XSL stylesheet won't work:

Code:

<?xml version='1.0' encoding='utf-8'?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
<xsl:template match='people'>
<xsl:for-each select='person'>
<b><xsl:value-of select='name' /></b>
<br /><i><xsl:value-of select='job' /></i>
<br /><img src='<xsl:value-of select='picture' />' />
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Note that the markup might not be perfect, I wrote it on the fly.

Thanks for any help,
Peyton

Rad

Rad

thinking of something witty to put here
Status: Offline!

How about...

Code:


<br /><img src="<xsl:value-of select='picture' />" />


Notice single and double quotes.

Peyton

Peyton

Status: Offline!

I tried that as well. I've also tried CDATA.

Demonx

Demonx

Status: Offline!

Did a search on google got this:

http://www.dpawson.co.uk/xsl/sect2/N4622.html

___________________

There are 10 types of people in the world: those who understand binary, and those who don't.

Peyton

Peyton

Status: Offline!

Thanks.

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0074 seconds.