Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • trfletch 595 posts 571 karma points
    Dec 14, 2009 @ 17:20
    trfletch
    0

    onClick javascript in XSLT causing error (highslide swf video)

    Hi all,

    I am running an Umbraco V4 website and I am trying to use highslide (highslide.com) to display a pop-up swf flash file using XSLT. Basically I have a Videos page that is going to have child nodes (videos) which have a media picker document property that is a swf file. I want the Videos page to list all the child pages and when you click on the link the video pops up and plays. I have the following code but I am getting an XLST error when trying to save it and I assume it is because I am putting javascript code in an XSLT file. Does anyone know what I need to do to get around this issue? Thanks in advance for any help offered. The XSLT I currently have is as follows:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
     exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <xsl:template match="/">
    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">
    <a href="{umbraco.library:GetMedia(data [@alias = 'video'], 'false')/data[@alias='umbracoFile']}" onclick="return hs.htmlExpand(this, { objectType: 'swf', width: 300,
      objectWidth: 300, objectHeight: 250, maincontentText: 'You need to upgrade your Flash player',
      swfOptions: { version: '7' }  } )"
      class="highslide">
    <xsl:value-of select="@nodeName"/>
    </a>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>

    The XSLT error I get when I try and save this is:

    System.Xml.Xsl.XslLoadException: Expected token '}', found ':'. 
    ...hs.htmlExpand(this, { objectType -->:<-- 'swf', width: 300, objectWidt... An error occurred at C:\webpub\globaltechnical\www\xslt\633964044873133491_temp.xslt(18,1).
    at System.Xml.Xsl.XslCompiledTransform.LoadInternal(Object stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at System.Xml.Xsl.XslCompiledTransform.Load(XmlReader stylesheet, XsltSettings settings, XmlResolver stylesheetResolver)
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
  • dandrayne 1138 posts 2262 karma points
    Dec 14, 2009 @ 17:29
    dandrayne
    1

    You could try something like

    <xsl:attribute name="onclick">
    <xsl:comment>
    javascript
    </xsl:comment>
    </xsl:attribute>

    or using a cdata block instead of the comment.

    Dan

  • trfletch 595 posts 571 karma points
    Dec 14, 2009 @ 18:03
    trfletch
    0

    Excellent, thanks Dan that worked but had to remove the <xsl:comment> part because it was causing an XSLT error on the page. I love this forum!

  • dandrayne 1138 posts 2262 karma points
    Dec 14, 2009 @ 18:13
    dandrayne
    0

    Heh no probs, now if only I had time to test snippets before posting them!

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies