Copied to clipboard

Flag this post as spam?

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


  • Ronald 1 post 21 karma points
    Mar 07, 2012 @ 08:07
    Ronald
    0

    Share icons from ShareThis through XSLT macro bug in IE

    When using the XSLT script from ShareThis to create a macro, the icons appear in the bottom part of the page where they should appear in the middle. Works fine in Firefox and Safari.

    Also the CMS itself gets really slow with this macro.

    This is the XSLT I'm using:

    <?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="/">

    <!-- start writing XSLT -->
     
      <script type="text/javascript">var switchTo5x=true;</script><script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'1ee1a6fb-f946-4c4b-b6ca-f118adf6cbed'});</script>
     
      <span  class='st_twitter_hcount' displayText='Tweet'></span><span  class='st_facebook_hcount' displayText='Facebook'></span><span  class='st_fblike_hcount' ></span><span  class='st_plusone_hcount' ></span>

    </xsl:template>

    </xsl:stylesheet>

  • Lee Kelleher 4026 posts 15836 karma points MVP 13x admin c-trib
    Mar 07, 2012 @ 13:03
    Lee Kelleher
    1

    Hi Ronald,

    Quick fix: Change the output method of the XSLT from "xml" to "html":

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

    The reason behind this is that if the output is set to "xml", then HTML tags like <script></script> are considered to be empty tags, so the XSLT will self-close them into "<script/>" ... which is valid XML, but will valid HTML (or that any web-browser will bork over it!).

    Cheers, Lee.

  • Greg 1 post 21 karma points
    Mar 08, 2012 @ 00:55
    Greg
    0

    You can leave the output method to XML. What is happening is that the span tag is transformed to a self-closing element. 

    The sharethis javascript does not perform its dom manipulations correctly when this is the case; adding span elements to the bottom of your document. So, your XSL has to enforce that there is a closing span tag. You could check for a :   span[not(node())]

    My solution is :  

    Added this to my source document :  <div id="shareThis"> </div>

    Then in my XSL - where my namespspace is xhtml ( change to yours or delete if not using namespace ) :

    <xsl:template match="xhtml:div[@id='shareThis']">   

    <xsl:copy>

    <xsl:apply-templates select="@*"/>

    <span class="st_facebook_large"><xsl:text> </xsl:text></span>

    <span class="st_twitter_large"><xsl:text> </xsl:text></span>

    </xsl:copy>

    </xsl:template>

    Works for me.

     

Please Sign in or register to post replies

Write your reply to:

Draft