?
Solved

XSL ampersand in the url

Posted on 2003-03-04
4
Medium Priority
?
1,401 Views
Last Modified: 2013-11-19
Ok, This is my 3rd day working with xml and I've read and read posts on how to accomplish this and still can't get it to work correctly.

I have an image tag that is dynamic.  The src= line posts to a funky .asp page that fetches the correct image and displays it.

If I paste this in my xsl file it works fine.

<IMG src="https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&i=453621&d=ID:+STUDENT+PHOTO" width="150" height="200" border="0" />

the problem comes in when I attempt to change the value of i= in there.  That is supposed to be the id number of the record I'm displaying other info about (<xsl:value-of select="IDNumber"/>)

I've attmepted to break it apart into element and attributes but then it complains about the apersand whether I use it straight or use &amp;

Any ideas ?
0
Comment
Question by:netlurch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:aaronchan
ID: 8067328
Hi netlurch,

Based on your code:

<IMG src="https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&i=453621&d=ID:+STUDENT+PHOTO" width="150" height="200" border="0" />

There are two ways you can accomplsih this:

First:
<IMG width="150" height="200" border="0">
  <xsl:attribute name="src">
https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&d=ID:+STUDENT+PHOTO&i= 
<xsl:value-of select="IDNumber"/>
  </xsl:attribute>
</IMG>

Second:
<IMG width="150" height="200" border="0"
src="https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&i={<xsl:value-of select="IDNumber"/>}&amp;d=ID:+STUDENT+PHOTO" />

Hope this would help.  Good luck!
0
 

Author Comment

by:netlurch
ID: 8071498
Thanks for the suggestions, I tried both of these.

The first one with the attribute I get this :

"This is an unexpected token. Expected 'SEMICOLON'. Line 77, position 48"

This is the line with the https://... in it and its catching in the &amp;s.  If I take them out it 'works'  doesn't pull the image, but no error.

The second example gives this message :
"'<', hexadecimal value 0x3C, is an invalid attribute character. Line 75, position 108." which I believe is the beginning of the <xsl... tag

Those were both great ideas, I had attempted something similar to both and was getting the same errors, I just figured it was because I was a newbie.
0
 
LVL 5

Accepted Solution

by:
aaronchan earned 120 total points
ID: 8072133
Hi netlurch,

I checked through the codes again, and found out I have made a mistake on the second case.  Sorry about that.  Also, I added "//" on your IDNumber to correctly locate the element.  As for the first case, try not to include any unnecessary lines or space.  

The following should be the proper way:

<IMG width="150" height="200" border="0"><xsl:attribute name="src">https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&d=ID:+STUDENT+PHOTO&i=<xsl:value-of select="//IDNumber"/></xsl:attribute></IMG>

Second:
<IMG width="150" height="200" border="0" src="https://docs.myserver.com/wx/MCGetDoc.asp?s=s&a=2&i={//IDNumber}&amp;d=ID:+STUDENT+PHOTO"/>

And just in case if you haven't already done so, these code need to sit within the main template:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
     <xsl:template match="/">
...your code here...
</xsl:template>
</xsl:stylesheet>

Good luck.
0
 

Author Comment

by:netlurch
ID: 8090009
aaronchan,

First one still doesn't work .... but the second one works like a charm !

Thanks for all the help !

 -Jon
0

Featured Post

CHALLENGE LAB: Troubleshooting Connectivity Issues

Goal: Fix the connectivity issue in the lab's AWS environment so that you can SSH into the provided EC2 instance.  

Question has a verified solution.

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

Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
JavaScript has plenty of pieces of code people often just copy/paste from somewhere but never quite fully understand. Self-Executing functions are just one good example that I'll try to demystify here.
The viewer will learn how to count occurrences of each item in an array.
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
Suggested Courses

777 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