[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.2

Updating the src attribute using an XSLT

Asked by eromanowski in XSL Formatting Objects, Extensible Markup Language (XML)

Tags: XSLT, XSL, XML

Hello Experts,

I'm new to XSl and I'm trying to update the src attribute on the <img> tag of my xml file and I am not having any luck.  I went into visual studio to debug and found that it is only hitting this block:

      <xsl:template match="*|@*">
                  <xsl:copy>
                        <xsl:apply-templates select="node()|@*|text()"/>
                  </xsl:copy>
      </xsl:template>

Thanks in advance.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
XSLT:
 
 
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="yes"/>
	
	
	<xsl:template match="*|@*">
			<xsl:copy>
				<xsl:apply-templates select="node()|@*|text()"/>
			</xsl:copy>
	</xsl:template>
 
	<xsl:template match="body">
		<span class="HSBody" dir="{@dir}"><xsl:apply-templates/></span>	
	</xsl:template>
	
	<xsl:template name="Page" match="Page">
			<xsl:choose>
				<xsl:when test="(count(following-sibling::Page) > 0)">
					<!-- force a page break if this isn't the last page -->
					<xsl:apply-templates/>
					<br style="page-break-after:always;"/>
				</xsl:when>
				<xsl:otherwise>
					<xsl:apply-templates/>
				</xsl:otherwise>
			</xsl:choose>		
	</xsl:template>
 
 
	<xsl:template match="img">
		<xsl:choose>
			<xsl:when test="@title and @title != ''">
				<table border="0" cellpadding="0" cellspacing="0" align="{@class}" width="{@width}">
					<tr>
						<td>
							<xsl:choose>
								<xsl:when test="@expandedimageid != '' and @expandedimageid">
									<!--NewWindow function sets exp img display window to size of Exp Image height & width without displayng toolbars etc. Additional pixels added to windows height & width to offset bordering imposed by browser -->
									<a href="javascript:NewWindow('/utils/GetImage.aspx?id={@expandedimageid}&amp;expimgheight={@expimgheight}&amp;expimgwidth={@expimgwidth}', 'ExpImageWindow', true, false, '{@expimgwidth+20}','{@expimgheight+25}', '');"><img src="/utils/GetImage.aspx?id={@imageid}" alt="{@alt}" height="{@height}" width="{@width}" class="{@class}" /></a>
								</xsl:when>
     						<xsl:otherwise>
									<img src="/utils/GetImage.aspx?id={@imageid}" alt="{@alt}" height="{@height}" width="{@width}" align="{@class}" class="{@class}"/>
								</xsl:otherwise>
							</xsl:choose>
						</td>
					</tr>
					<tr>
						<td align="center" class="caption">
							<b><xsl:value-of select="@title" /></b>
						</td>
					</tr>
				</table>	
			</xsl:when>
			<xsl:otherwise>
				<xsl:choose>
					<xsl:when test="@expandedimageid != '' and @expandedimageid">
 
						<a href="javascript:NewWindow('/utils/GetUCRImage.aspx?id={@expandedimageid}&amp;expimgheight={@expimgheight}&amp;expimgwidth={@expimgwidth}', 'ExpImageWindow', true, false, '{@expimgwidth+20}','{@expimgheight+25}', '');"><img src="/utils/
GetImage.aspx?id={@imageid}" alt="{@alt}" height="{@height}" width="{@width}" /></a>
					</xsl:when>
         			<xsl:otherwise>
         				<xsl:variable name="style"><xsl:if test="@class = 'left' or @class = 'right'">float:<xsl:value-of select="@class"/>;</xsl:if></xsl:variable>
						<img src="/utils/GetImage.aspx?id={@imageid}" alt="{@alt}" height="{@height}" width="{@width}" style="{$style}" />
					</xsl:otherwise>
				</xsl:choose>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
 
	
	<xsl:template match="Section">
		<div>
			<xsl:apply-templates/>
		</div>
		<br clear="all" />
	</xsl:template>
	
	<xsl:template match="Box">
		<table class="box" align="{@class}" width="{@width}">
		  <caption><xsl:value-of select="@title" /></caption>
		  <tr><td><xsl:apply-templates/></td></tr>
		</table>
	</xsl:template>
	
	<xsl:template match="Hotfield">
		<Hotfield id="{@hotfieldid}">
		  <xsl:apply-templates/>
		</Hotfield>
	</xsl:template>
 
 
	<xsl:template match="table [@type='row']">
   		 <table cellpadding="3" cellspacing="1" border="0" align="{@class}" width="{@width}">
   			<xsl:if test="@title != ''"><caption class="charthead"><xsl:value-of select="@title" /></caption></xsl:if>
			<xsl:apply-templates mode="row"/>
		</table>
	</xsl:template>
	
	<xsl:template match="caption" mode="row">
		<caption class="charthead"><xsl:apply-templates /></caption>
	</xsl:template>
	
	<xsl:template match="tr" mode="row">
		<tr>
			<xsl:apply-templates mode="row"/>
		</tr>
	</xsl:template>
	
	<xsl:template match="th" mode="row">
		<!-- set the colspan if it exists, otherwise, treat it as a 'sub-caption' that spans all columns -->
		<xsl:choose>
			<xsl:when test="@colspan !='' and @colspan">
				<th colspan="{@colspan}" class="chartsub" align="left">
					<xsl:apply-templates mode="row"/>
				</th>
			</xsl:when>
			<xsl:otherwise>
					<th class="chartsub" align="left">
						<xsl:apply-templates mode="row"/>
					</th>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	
	<xsl:template match="td" mode="row">
		<xsl:if test="count(parent::*/preceding-sibling::*) mod 2 = 1">
			<td colspan="{@colspan}" class="chartcolor1" valign="{@valign}"  width="{@width}">
				<xsl:apply-templates/>
			</td>
		</xsl:if>
		<xsl:if test="count(parent::*/preceding-sibling::*) mod 2 = 0">
			<td colspan="{@colspan}" class="chartcolor2" valign="{@valign}"  width="{@width}">
				<xsl:apply-templates/>
			</td>
		</xsl:if>
	</xsl:template>
 
	<xsl:template match="table [@type='column']">
		<table border="0" cellpadding="2" cellspacing="0" bordercolor="#FFFFFF" align="{@class}" width="{@width}">
   			<xsl:if test="@title != ''"><caption class="charthead"><xsl:value-of select="@title" /></caption></xsl:if>
			<xsl:apply-templates mode="column"/>
		</table>
	</xsl:template>
	<xsl:template match="caption" mode="column">
		<caption class="charthead"><xsl:apply-templates /></caption>
	</xsl:template>
 
	<xsl:template match="tr" mode="column">
		<tr>
			<xsl:apply-templates mode="column"/>
		</tr>
	</xsl:template>
	
	<xsl:template match="th" mode="column">
		<th colspan="{@colspan}" class="head{position() mod 2}">
			<xsl:apply-templates/>
		</th>
	</xsl:template>
	
	<xsl:template match="td" mode="column">
		<td valign="{@valign}"  colspan="{@colspan}" class="cell{position() mod 2}" width="{@width}">
			<xsl:apply-templates/>
		</td>
	</xsl:template>
	
	<xsl:template match="table [@type='grid']">
		<table border="1" cellpadding="2" cellspacing="0" align="{@class}" width="{@width}">
   			<xsl:if test="@title != ''"><caption class="charthead"><xsl:value-of select="@title" /></caption></xsl:if>
			<xsl:apply-templates mode="grid"/>
		</table>
	</xsl:template>
	<xsl:template match="caption" mode="grid">
		<caption class="charthead"><xsl:apply-templates /></caption>
	</xsl:template>
	<xsl:template match="tr" mode="grid">
		<tr>
			<xsl:apply-templates mode="grid"/>
		</tr>
	</xsl:template>
	<xsl:template match="th" mode="grid">
		<th colspan="{@colspan}" class="head0">
			<xsl:apply-templates />
		</th>
	</xsl:template>
	<xsl:template match="td" mode="grid">
		<td align="center" valign="{@valign}" colspan="{@colspan}" class="cellgrid" width="{@width}" >
			<xsl:apply-templates />
		</td>
	</xsl:template>
 
	<xsl:template match="table">
		<table border="0" cellpadding="2" cellspacing="0" align="{@class}" width="{@width}">
   			<xsl:if test="@title != ''"><caption class="charthead"><xsl:value-of select="@title" /></caption></xsl:if>
			<xsl:apply-templates mode="standard"/>
		</table>
	</xsl:template>
	<xsl:template match="caption" mode="standard">
		<caption class="charthead"><xsl:apply-templates /></caption>
	</xsl:template>
	<xsl:template match="tr" mode="standard">
		<tr>
			<xsl:apply-templates mode="standard"/>
		</tr>
	</xsl:template>
	<xsl:template match="th" mode="standard">
		<th colspan="{@colspan}" class="head0">
			<xsl:apply-templates />
		</th>
	</xsl:template>
	<xsl:template match="td" mode="standard">
			<td align="{@align}" valign="{@valign}" colspan="{@colspan}" class="cell0" width="{@width}" >
				<xsl:apply-templates />
			</td>
	</xsl:template>
 
	<xsl:template match="blockquote">
		<xsl:apply-templates/>
	</xsl:template>
 
	<xsl:template match="br">
		<br />
	</xsl:template>
 
</xsl:stylesheet>
 
 
XML:
 
 
<?xml version="1.0" encoding="utf-8" ?>
<Document ContentTypeId="3" ContentId="89525" IsCustom="0" xmlns="http://ws.something.com">
	<Content>
		<body xmlns="http://ws.something.com/markup">
			<h1>Paragraph</h1>
			<table type="standard">
				<tbody>
					<tr>
						<td valign="top">
							<p>When your body is working normally, the food you eat is digested and used as fuel. This fuel supplies energy to the bodys cells. When you have diabetes, the fuel cant enter the cells. Without treatment, diabetes can cause serious long-term health problems.</p>
						</td>
						<td>
							<p>
								<img imageidsrc="109335" alt="" height="361" width="358" class="right" title="Your body breaks down the food you eat into glucose." />
							</p>
						</td>
					</tr>
					<tr>
						<td valign="top">
							<h3>Paragraph 1</h3>
							<p>
								Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in nibh lorem, non lacinia nibh. Pellentesque egestas dui sit amet arcu blandit vulputate. Aliquam varius dapibus sapien, eget tristique quam vehicula et. Duis vitae nisi est, nec lobortis nunc. Vivamus eget metus quis libero sodales aliquet. Pellentesque facilisis dui eu nisi lobortis blandit. Proin vel eros ipsum. Duis tempus, turpis a imperdiet tempus, nisi nisl accumsan justo, ac fermentum nunc libero id nunc. Sed ullamcorper elementum enim quis bibendum. Proin dapibus tincidunt mi, quis condimentum est semper vitae. Nullam et nisi risus, id luctus turpis. 
							</p>
						</td>
						<td>
							<p>
								<img imageid="109336" alt="" height="310" width="339" class="right" />
							</p>
						</td>
					</tr>
				</tbody>
			</table>
			<h3> </h3>
			<h3> </h3>
			<h3>Paragraph 2</h3>
			<p>
				Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in nibh lorem, non lacinia nibh. Pellentesque egestas dui sit amet arcu blandit vulputate. Aliquam varius dapibus sapien, eget tristique quam vehicula et. Duis vitae nisi est, nec lobortis nunc. Vivamus eget metus quis libero sodales aliquet. Pellentesque facilisis dui eu nisi lobortis blandit. Proin vel eros ipsum. Duis tempus, turpis a imperdiet tempus, nisi nisl accumsan justo, ac fermentum nunc libero id nunc. Sed ullamcorper elementum enim quis bibendum. Proin dapibus tincidunt mi, quis condimentum est semper vitae. Nullam et nisi risus, id luctus turpis. 
			</p>
			<h3>Paragraph 3</h3>
			<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla in nibh lorem, non lacinia nibh. Pellentesque egestas dui sit amet arcu blandit vulputate. Aliquam varius dapibus sapien, eget tristique quam vehicula et. Duis vitae nisi est, nec lobortis nunc. Vivamus eget metus quis libero sodales aliquet. Pellentesque facilisis dui eu nisi lobortis blandit. Proin vel eros ipsum. Duis tempus, turpis a imperdiet tempus, nisi nisl accumsan justo, ac fermentum nunc libero id nunc. Sed ullamcorper elementum enim quis bibendum. Proin dapibus tincidunt mi, quis condimentum est semper vitae. Nullam et nisi risus, id luctus turpis. </p>
			<p>
				<img imageid="109337" alt="" height="257" width="343" />
			</p>
			<p> </p>
		</body>
	</Content>
</Document>
[+][-]09/02/09 03:41 PM, ID: 25246355Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zones: XSL Formatting Objects, Extensible Markup Language (XML)
Tags: XSLT, XSL, XML
Sign Up Now!
Solution Provided By: Gertone
Participating Experts: 1
Solution Grade: A
 
[+][-]09/02/09 06:49 PM, ID: 25247273Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/02/09 11:12 PM, ID: 25248200Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09/04/09 11:55 AM, ID: 25262323Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09/09/09 02:24 PM, ID: 25295738Administrative Comment

Experts Exchange has a courteous staff of administrators who help members get the most out of the website by means of administrative comments like this one.

Start your 30-day free trial to view this Administrative Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625