Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Reference to changing images in the xsl file?

Posted on 2004-11-18
6
Medium Priority
?
238 Views
Last Modified: 2012-06-27
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?
0
Comment
Question by:APConnextion
  • 4
  • 2
6 Comments
 
LVL 6

Accepted Solution

by:
PeterCiuffetti earned 2000 total points
ID: 12618718
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
 

Author Comment

by:APConnextion
ID: 12619685
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
 

Author Comment

by:APConnextion
ID: 12619736
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:APConnextion
ID: 12619944
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
 
LVL 6

Expert Comment

by:PeterCiuffetti
ID: 12625286
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
 

Author Comment

by:APConnextion
ID: 12626646
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month21 days, 7 hours left to enroll

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question