Copied to clipboard

Flag this post as spam?

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


  • Sam Ashton 4 posts 25 karma points
    Dec 16, 2013 @ 11:11
    Sam Ashton
    0

    XSLT video player macro issue

    Hi Guys, 

    First time posting here, copied an XSLT video player macro from a Umbraco 4.7.2 site into another Umbraco 4.0 site we have.

    The macro's are identical but the macro isn't running in 4.0, it produces no HTML or errors with all macro parameters holding values  

    Are there some syntax differences between these two versions or am i making a mistake.. XSLT isn't my native tongue, I'm more of a Razor guy.

    Could someone point me toward the issue?

    Thanks,

    Sam 

    :)

    <?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"
      exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <!-- set up vars -->
    <xsl:variable name "vidToPlay" select="/macro/vidToPlay"/>
    <xsl:variable name "previewImage" select="/macro/previewImage"/>
    <!-- END set up vars -->
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:if test="$vidToPlay != '' and $previewImage != '' ">
    <xsl:variable name="showMe" select="umbraco.library:GetMedia($vidToPlay/node/@id, 0)/data [@alias = 'umbracoFile']" />
    <xsl:variable name="preview" select="umbraco.library:GetMedia($previewImage/node/@id, 0)/data [@alias = 'umbracoFile']" />
    <video controls="" poster="{$preview}">  
    <source src="{$showMe}" type="video/mp4" />
    <object width="640" height="360" type="application/x-shockwave-flash" data="/media/12209/player.swf">
        <!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
        <param name="movie" value="/media/12209/player.swf" />
        <param name="flashvars" value='controlbar=over&amp;file={$showMe}' />    
      </object>
    </video>
      
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Dec 16, 2013 @ 12:01
    Dennis Aaen
    0

    Hi Sam,

    Yeah there are some syntax differences between these two versions. From Umbraco 4.5 and futher version the introduced a new XML schema. So thats way your XSLT code working in your 4.0 version and not in the 4.7.2 version.

    You can set, your Umbraco 4.7.2 to run with the old XML schema.

    Here is some resources to write XSLT to the new schema

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/xslt-examples-updated-to-new-schema

    http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/switching-between-old-and-new-schema

    I have just tried to rewrite your code from the top of my mind to work with the new schema.

    <?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"
      exclude-result-prefixes="msxml umbraco.library">
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
    <!-- set up vars -->
    <xsl:variable name = "vidToPlay" select="/macro/vidToPlay"/>
    <xsl:variable name = "previewImage" select="/macro/previewImage"/>
    <!-- END set up vars -->
    <xsl:template match="/">
    <!-- start writing XSLT -->
    <xsl:if test="$vidToPlay != '' and $previewImage != '' ">
    <xsl:variable name="showMe" select="umbraco.library:GetMedia($vidToPlay/@id, 0)/umbracoFile" />
    <xsl:variable name="preview" select="umbraco.library:GetMedia($previewImage/@id, 0)/umbracoFile" />
    <video controls="" poster="{$preview}"> 
    <source src="{$showMe}" type="video/mp4" />
    <object width="640" height="360" type="application/x-shockwave-flash" data="/media/12209/player.swf">
        <!-- Firefox uses the `data` attribute above, IE/Safari uses the param below -->
        <param name="movie" value="/media/12209/player.swf" />
        <param name="flashvars" value='controlbar=over&amp;file={$showMe}' />   
      </object>
    </video>
     
    </xsl:if>
    </xsl:template>
    </xsl:stylesheet>

    I hope this helps you.

    /Dennis

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Dec 16, 2013 @ 12:03
    Jeroen Breuer
    1

    Hello,

    In Umbraco the xml schema changed in 4.5 so your 4.7 xslt will probably work with the new xml schema. The 4.0 site uses the old schema so the xslt needs to be updated to work with the old schema. More info here: http://our.umbraco.org/wiki/reference/xslt/45-xml-schema

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft