Copied to clipboard

Flag this post as spam?

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


  • Amir Khan 1199 posts 2567 karma points
    Aug 18, 2010 @ 02:33
    Amir Khan
    0

    Passing a Macro Parameter Into a javascript string

    So, I'd like to pass a macro parameter into a javascript thing to allow and end user to insert a Flickr badge based on the set id. I think I'm doing something wrong with escaping the characters but I can't figure out what...I know the parameter is being passed from the macro because it renders when I leave it outside of the CDATA part

     

    here's the code I have:

    <?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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
    exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets tagsLib BlogLibrary ">


    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>


    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:value-of select="/macro/setid"/>
    <xsl:value-of select='\"'/macro/setid'\"'/>
    <xsl:text disable-output-escaping="yes"><![CDATA[
    <xsl:value-of select="/macro/setid"/>
    <xsl:value-of select="concat('\&quot;'/macro/setid'\&quot;')"/>
    <div class="flickr_badge_uber_wrapper">
    <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&count=10&display=latest&size=s&layout=x&source=user_set&user=43031198%40N02&set=<xsl:value-of select="/macro/setid"/>&context=in%2Fset-<xsl:value-of select="/macro/setid"/>%2F"></script>
    </div>
    ]]></xsl:text>
    </xsl:template>

    </xsl:stylesheet>

     

     

  • Chriztian Steinmeier 2726 posts 8320 karma points MVP 4x admin c-trib
    Aug 18, 2010 @ 02:50
    Chriztian Steinmeier
    0

    Hi Amir,

    Try this:

    <xsl:template match="/">
        <div class="flickr_badge_uber_wrapper">
            <script type="text/javascript" src="http://www.flickr.com/badge_code_v2.gne?show_name=1&amp;count=10&amp;display=latest&amp;size=s&amp;layout=x&amp;source=user_set&amp;user=43031198%40N02&amp;set={/macro/setid}&amp;context=in%2Fset-{/macro/setid}%2F">
                <xsl:comment>Prevent self-closing...</xsl:comment>
            </script>
        </div>
    </xsl:template>

    /Chriztian

  • Amir Khan 1199 posts 2567 karma points
    Aug 18, 2010 @ 17:31
    Amir Khan
    0

    Yes! Perfect, thank you Chriztian!

  • 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