Reference to changing images in the xsl file?

I have this code in my xsl file currently for an ImageFrame:

<IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute" SRC="SCVwp\scv101.jpg"/>

The SRC= portion needs to get the reference for the picture location from a field in the xml file called txtWebImageName.

How do I do this?
APConnextionAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

PeterCiuffettiCommented:
There are 2 ways to do it.  One is called an attribute value template where you reference an xsl:variable inside {}

And the other is to use the xsl:attribute instruction.  here is an example of both.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="document">
<html>
      <head/>
      <body>
            <xsl:variable name="imgloc" select="txtWebImageName"/>
            <h1>Apporach 1 -attribute value template</h1>
            <IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute" SRC="{$imgloc}"/>
            <h1>Apporach 2 - xsl:attribute</h1>
            <IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute">
                  <xsl:attribute name="SRC">
                        <xsl:value-of select="txtWebImageName"/>
                  </xsl:attribute>
            </IMG>
      </body>
</html>
</xsl:template>

</xsl:stylesheet>

Given the following input doc:

<document>
  <txtWebImageName>SCVwp\scv101.jpg</txtWebImageName>
</document>

It will produce:

<html>
  <head></head>
  <body>
    <h1>Apporach 1 -attribute value template</h1>
    <IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute" SRC="SCVwp\scv101.jpg">
    <h1>Apporach 2 - xsl:attribute</h1>
    <IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute" SRC="SCVwp\scv101.jpg">
  </body>
</html>


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
APConnextionAuthor Commented:
I sincerely thought it was going to work. I must have something amiss. I'm currently using the variable method. Here is what is at the top of my document.

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:fx="#fx-functions" exclude-result-prefixes="msxsl fx">
    <xsl:output method="html" version="4.0" indent="yes" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"/>
    <xsl:template match="document" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <html>
            <head>
                <META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=UTF-8"/>

Then, when I get to the portion with the image information, here is what is says:

<xsl:variable name="imgloc" select="txtWebImageName"/>
                        <IMG id="ImageFrame" class="Style8" style="LEFT: 0.0833in; TOP: 0.5in; WIDTH: 1.25in; HEIGHT: 1in; BACKGROUND-COLOR: silver; POSITION: absolute" SRC="{$imgloc}"/>

Do you see anything that I'm doing wrong?
                              
0
APConnextionAuthor Commented:
Actually, xsl:template match="//dataroot"  is what is up there. Not document.

And a portion of my xml document looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<dataroot xmlns:od="urn:schemas-microsoft-com:officedata" generated="2004-11-18T15:53:56">
<Qscv-central>
<Print>1</Print>
<SMA>SCV</SMA>
<New>0</New>
<SS>0</SS>
<Area>Central</Area>
<Address>1701 Industrial Street</Address>
<Rent>0</Rent>
<PropName>Meadow Valley Estates</PropName>
<Phone1>(715) 684-3312</Phone1>
<Heat>0</Heat>
<Elec>0</Elec>
<W_x002F_S>0</W_x002F_S>
<Refrigerator>1</Refrigerator>
<Range_x002F_Oven>1</Range_x002F_Oven>
<Dishwasher>0</Dishwasher>
<Disposer>0</Disposer>
<Microwave>0</Microwave>
<Avail>Now</Avail>
<ListingID>106</ListingID>
<City>Hudson</City>
<Bedrooms>0</Bedrooms>
<Bathrooms>0</Bathrooms>
<Total_x0020_Rooms>0</Total_x0020_Rooms>
<Hot_x0020_Water>0</Hot_x0020_Water>
<Trash>0</Trash>
<Campus>0</Campus>
<ImageID>6</ImageID>
<txtWebImageName>SCVwp\scv106.jpg</txtWebImageName>
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

APConnextionAuthor Commented:
Never mind that! It worked! My browser wasn't working properly. :-)  I award you the points!

I do have another question though.  It's about pagination. Would you like me to ask it seperately?
0
PeterCiuffettiCommented:
Yeah, its common practice to pose different questions as their own topic.  This help users who retrieve the questions and answers later for their own benefit.
0
APConnextionAuthor Commented:
Okay, will do. It's about pagination. If you know how to help, please take a peek. And thanks again for your help! You're fabulous! :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.