Copied to clipboard

Flag this post as spam?

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


  • Bas Wensveen 54 posts 75 karma points
    May 31, 2010 @ 20:54
    Bas Wensveen
    0

    Javascript from XSLT

    Hi,

     

    I want to output the following HTML and javascript code from a xslt file, but I didn't succed. Does some one have a suggestion?

     

             <p id="audioplayer_1">
                Alternative content</p>
             <script type="text/javascript">            AudioPlayer.embed("audioplayer_1", { soundFile: "/audio/track1.mp3" });</script>

     

    Kind regards

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 31, 2010 @ 21:19
    Dirk De Grave
    1

    Can you try wrapping that as

    <xsl:text disable-output-escaping="yes"><![CDATA[<script type="text/javascript">AudioPlayer.embed("audioplayer_1", { soundFile: "/audio/track1.mp3" });</script>]]></xsl:text>

    (not sure if that would work tho...)

     

    Cheers,

    /Dirk

  • Bas Wensveen 54 posts 75 karma points
    May 31, 2010 @ 21:48
    Bas Wensveen
    0

    Hy Dirk,

     

    The following text is send to my browser. Somehow the < characters are replaced with &lt. 

     

                          &lt;script type="text/javascript"&gt;AudioPlayer.embed("audioplayer_1",{ soundFile: "/audio/track1.mp3" });&lt;/script&gt;}       
  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    May 31, 2010 @ 22:46
    Dirk De Grave
    0

    Ok, just tested that on a local install, don't have that issue, so in theory that should work... 

    Did you set disable-output-escaping="yes", as when omitting this, it will be sent to browser as you've experienced...

    Cheers,

    /Dirk

     

     

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 31, 2010 @ 22:50
    Chriztian Steinmeier
    0

    Hi Bas,

    How are you doing the output - I don't see why your initial example would fail, if included as literal output from a template, e.g.:

    <xsl:template match="/">
        <p id="audioplayer_1">
            Alternative content
        </p>
        <script type="text/javascript">
            AudioPlayer.embed("audioplayer_1", { soundFile: "/audio/track1.mp3" });
        </script>
    </xsl:template>
    

    Are you by any chance, creating the content programmatically? 

    /Chriztian

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jun 01, 2010 @ 16:14
    Douglas Robar
    0

    Another potential issue that could mess things up... be sure your xslt is set to output xml, rather than html, text, or something else.

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

    If you still can't get it working, please paste in your entire xslt file for us to look at.

    cheers,
    doug.

  • Bas Wensveen 54 posts 75 karma points
    Jun 01, 2010 @ 21:22
    Bas Wensveen
    0

    Hi Douglas,

     

     

    I use a variable to output the HTML and forgot to add omit-xml-declaration="yes".

     

    Thanks!

     

    Regards

Please Sign in or register to post replies

Write your reply to:

Draft