Copied to clipboard

Flag this post as spam?

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


  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 02, 2010 @ 23:12
    Nik Wahlberg
    0

    Key grouping producing different results

    Hi, I am using the following XSLT to output events and group them by month. Now, this produces the exact results that I would expect in my development environment, but in the production site I get no output. 

    <?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"/>
    
      <!-- Input the documenttype you want here -->
      <xsl:variable name="documentTypeAlias" select="string('Event')"/>
      <xsl:variable name="now" select="umbraco.library:CurrentDate()" />
      <xsl:variable name="groupByAlias" select="string('eventStartDate')"/>
      <xsl:key name="nodesByMMMM" match="node" use="umbraco.library:FormatDateTime(data [@alias='eventStartDate'],'MMMM')"/>
    
      <xsl:template match="/">
    
        <xsl:variable name="eventNodes" select="$currentPage/node [
                      @nodeTypeAlias = $documentTypeAlias and 
                      string(data [@alias='umbracoNaviHide']) != '1' and 
                      (data [@alias = 'eventStartDate'] != '' and umbraco.library:DateGreaterThanOrEqualToday(data [@alias = 'eventStartDate']))]" />
    
    
    
        <!-- The fun starts here -->
        <xsl:choose>
          <xsl:when test="count($eventNodes)!=0">
    
            <xsl:for-each select="$eventNodes[count(. | key('nodesByMMMM', string(umbraco.library:FormatDateTime(data [@alias=$groupByAlias],'MMMM')))[1]) = 1]">
              <h2 class="dotted">
                <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias=$groupByAlias],'MMMM - yyyy')" />
              </h2>
    
              <div class="ctr-events">
                <ul>
                  <xsl:for-each select="key('nodesByMMMM', umbraco.library:FormatDateTime(data [@alias=$groupByAlias],'MMMM'))">
                    <xsl:sort select="data [@alias=$groupByAlias]" order="ascending"/>
                    <li>
                      <div class="cal-style">
                        <span class="day-txt">
                          <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias=$groupByAlias], 'ddd')"/>
                        </span>
                        <span class="daymonth-txt">
                          <xsl:value-of select="umbraco.library:FormatDateTime(data [@alias=$groupByAlias], ' d')"/>
                        </span>
                      </div>
                      <div class="info">
                        <div class="title">
                          <a href="{umbraco.library:NiceUrl(@id)}">
                            <xsl:value-of select="@nodeName"/>
                          </a>
                        </div>
                        <span class="location">
                          Location:
                          <span class="bold">
                            <xsl:value-of select="data [@alias = 'eventPrimaryLocation']"/>
                          </span>
                        </span>
                      </div>
                      <div class="clear"></div>
                    </li>
                  </xsl:for-each>
                </ul>
              </div>
            </xsl:for-each>
          </xsl:when>
          <xsl:otherwise>
            <p>There are no upcoming events. Please check back soon.</p>
          </xsl:otherwise>
        </xsl:choose>
    
    
      </xsl:template>
    
    </xsl:stylesheet>

    I have checked that my 'eventNodes' in fact return nodes so the data is there. But my first key(...) grouping returns nothing! Doing a copy-of gives me no nodes in produciton. Can anyone think of why this is? I am baffled and have been stuck on this for a couple of hours!

    Thanks,
    Nik

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 02, 2010 @ 23:16
    Nik Wahlberg
    0

    Btw, here is the copy-of result from $eventNodes in production: 

    <node id="13127" version="c4bfc364-a19d-4741-9a3d-b70439e89d72" parentID="1066" level="3" writerID="1" creatorID="1" nodeType="1047" template="1192" sortOrder="10" createDate="2010-01-06T13:56:50" updateDate="2010-01-06T13:58:56" nodeName="2010 Town Meeting February 2" urlName="2010-town-meeting-february-2" writerName="Charlotte Minasian" creatorName="Charlotte Minasian" nodeTypeAlias="Event" path="-1,1059,1066,13127">
          <data alias="eventDescription">Meet Ken Hanover, NHS President and CEO and hear about the state of the organization.</data>
          <data alias="eventFeaturedSpeakers">Ken Hanover</data>
          <data alias="eventStartDate">2010-02-02T14:30:00</data>
          <data alias="eventEndDate">2010-02-02T13:30:00</data>
          <data alias="eventPrimaryLocation">Beverly Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Lecture Hall</data>
          <data alias="eventVideoconferencingAvailable">0</data>
          <data alias="eventIfVideoconferencing" />
          <data alias="eventVideoconferencingWhere" />
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Donna Coskren</data>
          <data alias="eventContactDepartment">Marketing</data>
          <data alias="eventContactPhone">TZ-1663</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias="eventIsActive">1</data>
        </node>
        <node id="13128" version="b48f92bb-aedf-4334-8f16-7d23a2589211" parentID="1066" level="3" writerID="1" creatorID="1" nodeType="1047" template="1192" sortOrder="11" createDate="2010-01-06T13:59:22" updateDate="2010-01-06T14:01:18" nodeName="2010 Town Meeting February 4" urlName="2010-town-meeting-february-4" writerName="Charlotte Minasian" creatorName="Charlotte Minasian" nodeTypeAlias="Event" path="-1,1059,1066,13128">
          <data alias="eventDescription">Meet Ken Hanover, NHS President and CEO and hear about the state of the organization.</data>
          <data alias="eventFeaturedSpeakers">Ken Hanover</data>
          <data alias="eventStartDate">2010-02-04T15:30:00</data>
          <data alias="eventEndDate">2010-02-04T16:30:00</data>
          <data alias="eventPrimaryLocation">Beverly Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Lecture Hall</data>
          <data alias="eventVideoconferencingAvailable">0</data>
          <data alias="eventIfVideoconferencing" />
          <data alias="eventVideoconferencingWhere" />
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Donna Coskren</data>
          <data alias="eventContactDepartment">Marketing</data>
          <data alias="eventContactPhone">TZ-1663</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias="eventIsActive">1</data>
        </node>
        <node id="13129" version="60ded3a6-d8f6-49c3-bf93-b9ce16a89bc9" parentID="1066" level="3" writerID="1" creatorID="1" nodeType="1047" template="1192" sortOrder="12" createDate="2010-01-06T14:01:42" updateDate="2010-01-06T14:05:38" nodeName="2010 Town Meeting February 9" urlName="2010-town-meeting-february-9" writerName="Charlotte Minasian" creatorName="Charlotte Minasian" nodeTypeAlias="Event" path="-1,1059,1066,13129">
          <data alias="eventDescription">Meet Ken Hanover, NHS President and CEO and hear about the state of the organization.</data>
          <data alias="eventFeaturedSpeakers">Ken Hanover</data>
          <data alias="eventStartDate">2010-02-09T11:00:00</data>
          <data alias="eventEndDate">2010-02-09T12:00:00</data>
          <data alias="eventPrimaryLocation">Beverly Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Lecture Hall</data>
          <data alias="eventVideoconferencingAvailable">0</data>
          <data alias="eventIfVideoconferencing" />
          <data alias="eventVideoconferencingWhere" />
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Donna Coskren</data>
          <data alias="eventContactDepartment">Marketing</data>
          <data alias="eventContactPhone">TZ-1663</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias="eventIsActive">1</data>
        </node>
        <node id="13610" version="e3327375-2950-464c-804e-46754e070088" parentID="1066" level="3" writerID="1" creatorID="1" nodeType="1047" template="1192" sortOrder="13" createDate="2010-02-02T09:50:57" updateDate="2010-02-02T10:14:49" nodeName="2010 February 5 Pediatric Grand Rounds" urlName="2010-february-5-pediatric-grand-rounds" writerName="Charlotte Minasian" creatorName="Charlotte Minasian" nodeTypeAlias="Event" path="-1,1059,1066,13610">
          <data alias="eventDescription">Lecture Title: Periodic Fever Syndromes of Childhood.</data>
          <data alias="eventFeaturedSpeakers">Ian Michelow, M.D. </data>
          <data alias="eventStartDate">2010-02-05T08:30:00</data>
          <data alias="eventEndDate">2010-02-05T09:30:00</data>
          <data alias="eventPrimaryLocation">Beverly Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Doctors' Conference Room</data>
          <data alias="eventVideoconferencingAvailable">0</data>
          <data alias="eventIfVideoconferencing" />
          <data alias="eventVideoconferencingWhere" />
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Denise Pyburn</data>
          <data alias="eventContactDepartment">Medical Staff Office</data>
          <data alias="eventContactPhone">BH-2729</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias="eventIsActive">1</data>
        </node>
        <node id="11856" version="72bd4363-8b85-4960-a9e1-5b571b2b3cea" parentID="1066" level="3" writerID="1" creatorID="0" nodeType="1047" template="1192" sortOrder="14" createDate="2009-08-25T17:02:23" updateDate="2010-02-02T10:12:46" nodeName="2010 February 16 AGH-ONCOLOGY CONFERENCE" urlName="2010-february-16-agh-oncology-conference" writerName="Charlotte Minasian" creatorName="Administrator" nodeTypeAlias="Event" path="-1,1059,1066,11856">
          <data alias="eventDescription">Oncology cases reviewed.</data>
          <data alias="eventFeaturedSpeakers">Angus McIntyre, M.D.</data>
          <data alias="eventStartDate">2010-02-16T08:00:00</data>
          <data alias="eventEndDate">2010-02-16T09:00:00</data>
          <data alias="eventPrimaryLocation">Addison Gilbert Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Library</data>
          <data alias="eventVideoconferencingAvailable">0</data>
          <data alias="eventIfVideoconferencing" />
          <data alias="eventVideoconferencingWhere" />
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Denise Pyburn</data>
          <data alias="eventContactDepartment">Medical Staff Office</data>
          <data alias="eventContactPhone">BH-2728</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias="eventIsActive">1</data>
        </node>
        <node id="11984" version="cb572897-1c27-4520-831c-174c4bdd79a5" parentID="1066" level="3" writerID="1" creatorID="1" nodeType="1047" template="1192" sortOrder="15" createDate="2009-09-03T16:00:02" updateDate="2010-02-02T10:14:27" nodeName="2010 February 22 Schwartz Center Rounds" urlName="2010-february-22-schwartz-center-rounds" writerName="Charlotte Minasian" creatorName="Charlotte Minasian" nodeTypeAlias="Event" path="-1,1059,1066,11984">
          <data alias="eventDescription">Medical Service Conference: Schwartz Center Rounds</data>
          <data alias="eventFeaturedSpeakers" />
          <data alias="eventStartDate">2010-02-22T12:00:00</data>
          <data alias="eventEndDate">2010-02-22T13:00:00</data>
          <data alias="eventPrimaryLocation">Beverly Hospital</data>
          <data alias="eventOtherLocation" />
          <data alias="eventRoomLocation">Lecture Hall</data>
          <data alias="eventVideoconferencingAvailable">1</data>
          <data alias="eventIfVideoconferencing">BH @ Danvers</data>
          <data alias="eventVideoconferencingWhere">Addison Gilbert Hospital</data>
          <data alias="eventUrl" />
          <data alias="eventPrice" />
          <data alias="eventContactName">Cheryl Merrill</data>
          <data alias="eventContactDepartment">Nursing Practice, Quality &amp; Education</data>
          <data alias="eventContactPhone">BH 2243</data>
          <data alias="eventContactEmail">[email protected]</data>
          <data alias="eventShowGlobal">1</data>
          <data alias=

    Thanks.

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Feb 02, 2010 @ 23:19
    Thomas Höhler
    0

    How is the dev made? a copy of the production? Check all properties for typos (especially case typos). Is the xml in sync, try republishing and check the date of the umbraco.config file. Recycle the app pool to get in sync...

    Also check the cache options of the macro.

    Also check the language settings of the installations (you are using dates...)

    just some shots in the dark...

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Feb 02, 2010 @ 23:41
    Nik Wahlberg
    0

    Hi Thomas and thanks for the tips...But if it was a cache or data mismatch my $eventNodes would be empty, right? The data seems to be there and the property names all match, but the following

    $eventNodes[count(. | key('nodesByMMMM', string(umbraco.library:FormatDateTime(data [@alias=$groupByAlias],'MMMM')))[1]) = 1]

    does not return any results! Oh, here is another weird finding....if I run the same XSLT in another part of the site I DO get results back....wtf? I was getting ALL of the events back not just the ones from $eventNodes but when I changes the nested for-each select to include $eventNodes[key(...)] I got only the ones that I expected. So, is my xsl:key match attribute messing me up (since it matches ALL 'node' elements)? 

    Thanks all! 

    -- Nik

Please Sign in or register to post replies

Write your reply to:

Draft