Copied to clipboard

Flag this post as spam?

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


  • Sergei.a 7 posts 27 karma points
    Oct 13, 2010 @ 15:53
    Sergei.a
    0

    XSLT issues on 4.5.2 with a previously working macro

    I'm porting a site over from an older version of Umbraco and attempting to update it to the most recent version of XSLT schema. The macro i'm trying to rewrite provides prev/next functionality for my news section. Here is the XSLT file:

    [CODE]

    <?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:variable name="picFile" select="count($currentPage/preceding-sibling::node)"/>
      <xsl:copy-of select="$picFile" />
      
        <xsl:if test="count($currentPage/preceding-sibling::node) != 0">
          <strong>Previous Article:</strong> &nbsp;
          <a href="{umbraco.library:NiceUrl($currentPage/preceding-sibling::node[1]/@id)}">
            <xsl:value-of select="$currentPage/preceding-sibling::node[1]/data ['entryTitle']"/>
          </a>
          <br />
        </xsl:if>
        <xsl:if test="count($currentPage/following-sibling::node) != 0">
          <strong>Next Article:</strong> &nbsp;
          <a href="{umbraco.library:NiceUrl($currentPage/following-sibling::node[1]/@id)}">
            <xsl:value-of select="$currentPage/following-sibling::node[1]/data ['entryTitle']"/>
          </a>
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>

    [/CODE]

    The problem is count($currentPage/preceding-sibling::node) always returns 0 when there are siblings on either side of the current node. This markup worked in 4.0 so i'm not sure if i'm missing some kind of attribute or what to match the new schema format.

    Any help appreciated. Thanks.

     

     

     

  • Sergei.a 7 posts 27 karma points
    Oct 13, 2010 @ 16:15
    Sergei.a
    0

    If someone could tell me how to post XSLT snippets here i'd be happy to repost my code. I keep getting an error trying to edit that post.

  • Sergei.a 7 posts 27 karma points
    Oct 14, 2010 @ 16:12
    Sergei.a
    0

    Well, seeing that I wouldn't get any help here, i thought i'd keep beating my head against the wall. Here is the solution if anyone cares.

    <?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:rssdatehelper="urn:rssdatehelper"
      xmlns:dc="http://purl.org/dc/elements/1.1/"
      xmlns:content="http://purl.org/rss/1.0/modules/content/"
      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:if test="count($currentPage/preceding-sibling::* [@isDoc]) != 0">
         « <a href="{umbraco.library:NiceUrl($currentPage/preceding-sibling::* [@isDoc][1]/@id)}">Previous</a>
        </xsl:if>&nbsp;
        <xsl:if test="count($currentPage/following-sibling::* [@isDoc]) != 0">
          <a href="{umbraco.library:NiceUrl($currentPage/following-sibling::* [@isDoc]/@id)}">Next</a> »
        </xsl:if>
      </xsl:template>
    </xsl:stylesheet>
  • Ian Smedley 97 posts 192 karma points
    Nov 11, 2010 @ 13:27
    Ian Smedley
    0

    If I had 70 karma points, I'd high-five! your answer - I had the same problem with the new 4.5 mark-up, your solution helped, cheers!

    Perhaps we should stick it in the wiki somewhere..

  • Sergei.a 7 posts 27 karma points
    Nov 11, 2010 @ 19:01
    Sergei.a
    0

    Glad this helped you out. It's a very common piece of functionality and as frustrating as the new markup changes are in 4.5, I wouldn't mind sticking it in the wiki.

Please Sign in or register to post replies

Write your reply to:

Draft