Using a complex url in xslt

Hi - this should be simple but of course never is.  I need to hardcode a url in xslt per the following simple example which works:

<xsl:variable name="URL" >
<a><xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>My Link</a>

However, if I atempt to use a Google map complex url string, it chokes on multiple "=" and "&" characters.  This happens also using  <xsl:variable name="url" select="'the url google string'" />.  It can't simply accept the string as-is without processing it I guess.

<xsl:variable name="URL" >

The Error message returned is:

Error: Error loading XSLT document.
XSLT compile error.'=' is an unexpected token. The expected token is ';'. Line 38, position 46. Line 38, position 46.
Line: 38
Position: 46

I'm a novice at this and just need to get it to work.

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.

You have to URL-encode that string.
Richard__GAuthor Commented:
Thanks, but I get the following and it does not work:
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

Richard__GAuthor Commented:
I tried this and it's a start, google maps comes up but the location is messed up somehow.  It brings up the US map and that's it.   Is there no way to simply have xsl treat it as a text string and not mess with it?
Geert BormansInformation ArchitectCommented:
there is really no need to url-encod this string.
it is not url decoding/encoding that i important but XML encoding
since the problem is originated at the xml parser, parsing the xslt

you should stuff the uri in a cdata section, than the parser doesn't bother about the &
        <xsl:variable name="URL" >
        <a><xsl:attribute name="href"><xsl:value-of select="$URL"/></xsl:attribute>My Link</a>

Open in new window


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
Richard__GAuthor Commented:
gave up. no solutions worked.
Geert BormansInformation ArchitectCommented:
it took you 9 months to understand that it didn't work and then give up?

please explain what doesn't work.
I am not sure how you tested my solution, if at all

I gave exactly the solution to your problem and it works at my end
My solution had been tested prior to posting, it worked back then, I just tested it again and it still works
using my code snippet gives a link in the resulting html
clicking the link leads me to the empire state building on google maps

CDATA sections are the answer to your problem, full stop

You should have asked more info when you were still experiencing problems, you still can by the way.
But I can't accept you to delete a question having a valuable working and tested solution as an answer
Richard__GAuthor Commented:
To be honest - I tried it, must have done it wrong, and gave up at that point.  No offence or insult was intended, my apologies, it was probably my fault. It was just one of many things I was dealing with at the time.

At this point I'd just like to delete the question.

Geert BormansInformation ArchitectCommented:
3) Accept: http:#a28386764

In the URL there is a string "&hnear="
An "&" starts an entity, and a limited set of tokens are allowed as characters in the name of the entity, "=" is not an allowed token
entity names end with a ";"
The parser is expecting a ";" instead of a "="
The "&" is not intended as an entity start but as the literal "&"
so it should be escaped for the XSLT to be wellformed
1. By using "&amp;" instead of "&" but that would require some work on the url
2. By wrapping the entire URL in a CDATA section as I did in the solution. Then a "&" is considered literal

Simple but effective answer to the problem stated
I recommend to keep it in the database (hence 4) since it is a common problem and the solution could be usefull to others
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
Web Languages and Standards

From novice to tech pro — start learning today.