Search

Ummm I'm trying to output an ampersand symbol & to render as & onthe front end in my xsl page template but it's just not playing ball.. saying:

loadXML(): EntityRef: expecting ';' in Entity, line: 18

And my code is as follows:

<a href="{banners/entry/link-url}?utm_source={$current-url}&utm_medium={banners/entry/type-of-banner/item}&utm_campaign={banners/entry/campaign-description}&utm_term={banners/entry/advert-description}&utm_content={banners/entry/advert-reference-id}" target="_blank"><img src="{$workspace}{banners/entry/alternative-image-banner/@path}/{banners/entry/alternative-image-banner/filename}" /></a>

If I change the & to $amp; it validates and renders fine on the front end.. but I want it to output as & for tracking purposes.. any thoughts?

You cannot output the & character verbatim in XHTML, it is invalid. If your link URL includes &amp; then this will be correctly interpreted e.g.

http://yoursite?utm_source=something&amp;utm_medium=somethingelse

That is perfectly fine.

Ok cool.. Got that bit working fine with &amp; now but I guess I'm trying to also place the same code on clickTag tracking elements on a flash object attribute and it doesn't like the &amp; and ignores everything after and including the first &amp; so I guess it's just gonna blow up :)

Using &#38; has worked for me, but i don't know whether it will work in your context.

Tried that.. here's what I have but everything after the &amp; is ignored in the URL clicked:

    <object type="application/x-shockwave-flash" 
        data="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}?clickTag={banners/entry/link-url}&amp;utm_source={$current-url}&amp;utm_medium={banners/entry/type-of-banner/item}&amp;utm_campaign={banners/entry/campaign-description}&amp;utm_term={banners/entry/advert-description}&amp;utm_content={banners/entry/advert-reference-id}" 
        width="350" height="300">
  <param name="movie" value="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}?clickTag={banners/entry/link-url}&amp;utm_source={$current-url}&amp;utm_medium={banners/entry/type-of-banner/item}&amp;utm_campaign={banners/entry/campaign-description}&amp;utm_term={banners/entry/advert-description}&amp;utm_content={banners/entry/advert-reference-id}" />
  <a href="{banners/entry/link-url}?utm_source={$current-url}&amp;utm_medium={banners/entry/type-of-banner/item}&amp;utm_campaign={banners/entry/campaign-description}&amp;utm_term={banners/entry/advert-description}&amp;&utm_content={banners/entry/advert-reference-id}" target="_blank"><img src="{$workspace}{banners/entry/alternative-image-banner/@path}/{banners/entry/alternative-image-banner/filename}" /></a>
</object>

It works on the a link attibute and the clickTag itself triggers but because there are semi colons in the object attribute it don't like it.

I've been mulling this over for hours, and the only idea I have is to try and use the <xsl:attribute> tag to add the data attribute.

This does raise a question though... How come you need click tracking inside an attribute who's sole purpose is to designate the origin of the object's content?

Is the click tracking for when someone clicks on the object? If so, then just wrap the object in an anchor with the tracking on it. Click tracking on the object, param and a nested anchor is a little excessive IMO... I guess you've done it for fallback, but avoid that by doing the click tracking first.

So wrapping it in an anchor and set the href to include the tracking data?

i.e

<a href="{banners/entry/link-url}?utm_source={$current-url}&amp;utm_medium={banners/entry/type-of-banner/item}&amp;utm_campaign={banners/entry/campaign-description}&amp;utm_term={banners/entry/advert-description}&amp;&utm_content={banners/entry/advert-reference-id}" target="_blank">

<object type="application/x-shockwave-flash" 
        data="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}" 
        width="350" height="300">
  <param name="movie" value="{$workspace}{banners/entry/swf-banner/@path}/{banners/entry/swf-banner/filename}" />
  <img src="{$workspace}{banners/entry/alternative-image-banner/@path}/{banners/entry/alternative-image-banner/filename}" />
</object>
</a>

Just trying to simplify the way we can notify the outgoing links analytics of the origin of the banner advert.. possibly all wrong but I take your point about excessive.. yes it's for fallback purposes. but wrapping object in anchor is that valid?

Yeah, wrapping an object in an anchor is perfectly valid XHTML.

I hope it all works!

Sweet thanks desingermonkey. All purring away nicely now.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details