Welcome to AspAdvice Sign in | Join | Help

Many quick updates and first XSLT sample for SharePoint – Event Management System

Okay. Life has been rolling so very fast lately. Here are a few quick updates to as quickly as possible keep everyone updated:

Jan 24, 2009 – Second annual - HoustonTechFest – Presented “Building Powerful WebParts with SharePoint 2007” and “WCF for the REST of us”! Awesome audience participation!

Feb 7, 2009 – Presented at the first annual SharePoint Saturday KC - “Building Powerful WebParts with SharePoint 2007”. Becky Isserman and team did an awesome job! Attended some awesome presentations. Had some great BBQ with Daniel Larson!

March 1-5, 2009 – MVP Summit 09! Totally awesome. Got to see the Gu (Scott Guthrie) and hang out with a bunch of the SharePoint MVPs!

March 28, 2009 – Second annual School of Dev / first time to join with SharePoint Saturday! – about 87 people braved the weather reports to attend. It was just rain! Then 9am to 3pm had about 6+ inches of snow drop and stop. Within 24 hours 99.9% was all melted. Presented “Building Powerful WebParts with SharePoint 2007” and “Knowledge (Social) Networking for the Enterprise”

April 16, 2009 – White paper I wrote for Quest.com was republished on to the home page as a Popular Article on SSWUG.org – SQL Server and SharePoint – The More You Know, The Better Off You Are (if you are a paid member you can read it here.)

April 18, 2009 – St Louis MOSS Camp! Had a great time presenting – “Building Powerful WebParts with SharePoint 2007“ and attending the other sessions. Becky Isserman and Scott Spradlin talked me into playing Rock band with spoons for drum sticks, didn’t do too bad. LOL

April 25, 2009 – NWACodeCamp – awesome job! Especially for their first event! “Presented Building Powerful WebParts with SharePoint 2007”.

May 28, 2009 – Baby # 5 – Kadison Zoey-Mae Walker born, thanks to my beautiful wife!

 Kadison Zoey-Mae Walker, born March 28, 2009

June 1, 2009 – Two year term as Vice President of the INETA NORAM Speakers Bureau ended.

June 22, 2009 – 1st day at Microsoft as a ADC (Application Developer Consultant) – in Dallas at Las Colinas office for New Employee Orientation, after hours - attended DFW SharePoint group that night and saw Ted Pattison!

June 23, 2009 – Day 2 at Microsoft, after hours – attended Dallas ASP .NET User Group where Dr. Tobias Komischke, Director of User Experience @ Infragistics presented.

June 29, 2009 – Turned over Tulsa Developers .NET user group to the very capable Vice-President Sean Whitesell and the other groups to their respective leaders as well.

July 2, 2009 – My beautiful bride and I celebrated our 15th wedding anniversary

July 27-31, 2009 – TechReady 9 in Seattle. I thought the MVP Summit was huge. Wow. Amazing time, learned a lot, and met a lot of new people. Plus, folks I haven’t seen in awhile – Zewei Song, Michael Wiley, Steve Walker.. and lots of new friends!

Okay.. whew. There’s a whole lot more in there as well, between the monthly TulsaDevelopers.NET, Tulsa SQL Server Group, Tulsa SharePoint Interest Group and Tulsa Java Developers Group that I was involved with every month until recently due to my commute and some new NWASQL Server User Group meetings at lunch. But, my “quick” update has turned into a lot more.

Now… finally on to the code!

For those of you that haven’t seen my “Building Powerful WebParts for SharePoint 2007” session, I totally love writing code and utilizing SharePoint as an application development platform. But, it took several years and practically hundreds of contacts to find a hosting company able and generous enough to donate/sponsor a virtual server for the TulsaTechFest.com web site and for the Tulsa User Groups I am involved with.

Due to timing, I had to build out the site last year so quickly that I took the opportunity to explore the functionality of SharePoint Designer 2007 for the first time.

I utilized it to enable friendly url’s in SharePoint (can anyone say /Pages)? yuck!

I copied the 2008 content as a Site Template to kick start the 2009 site. But that left a lot of extra data, so I just recently added an “Active” Yes/No checkbox to the Speakers List. That’s one thing I’ve learned over the last 4 years of running large events, the agenda is bound to change up to the last minute.

Starting with Visual Studio 2008, it offered the excellent ability to debug XSLT! I took advantage of that, to deliver a no-code solution for the Event Management, by parsing the SharePoint List RSS feed utilizing XSLT. The default RSS feed is kind of gnarly to work with, but I’ve managed to work around it. (See my WSS_LIST_RSS_FIELDS.xsl distributed as part of my PowerQueryWebPart CodePlex project for a great reusable parser.)

Ironically, when I first added the Active filter to the xsl:for-each statement the xsl:sort quit sorting by the SortOrder number column. Very strange. Open in Visual Studio 2010 Beta 1, same results. Sleep on it. Deploy today, so I could share with the world and get some others input and boom – it works!

For some reason Visual Studio 2008 isn’t showing the Debug XSLT option every so often. Visual Studio 2010 Beta 1 is showing it with no issues. Reopened it and reran the Debug XSLT option and boom – working every time now. Very strange. I’ll chalk both issues up to Visual Studio 2010 Beta 1 testing. All working great now.

So, simply create a Speakers list with the following columns: Title (FirstName LastName), Bio, Link, Company, Tagline, SortOrder (Number), Active (Yes/No) and you’re ready to role!

I have a SiteImages Picture Library with a sub folder called Speakers where the images are stored: Title(spaces replaced with __).jpg.

The following XSLT shows a 3 column right rail for speakers filtered by Active flag, sorted by SortOrder, Title

<xsl:transform  version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
                exclude-result-prefixes="xsl xs" xmlns:ddwrt2="urn:frontpage:internal">
    <xsl:output method="html"/>

    <xsl:template match="rss/channel" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime">
        <table border="0" cellpadding="0" cellspacing="0">
            <tr>
                <td>
                    <xsl:for-each select="item[substring-before(substring-after(description, 'Active:&lt;/b&gt;'), '&lt;/div&gt;')=' Yes']">
                        <xsl:sort select="substring-before(substring-after(description, 'SortOrder:&lt;/b&gt;'), '&lt;/div&gt;')" data-type="number" order="ascending"/>
                        <xsl:sort select="title" />

                        <!--                        <xsl:if test="substring-before(substring-after(description, 'Active:&lt;/b&gt;'), '&lt;/div&gt;')=' Yes'">-->
                            <a>
                                <xsl:attribute name="href">
                                    <!--
                  <xsl:call-template name="getWSSDescriptionField">
                    <xsl:with-param name="description" select="description"/>
                    <xsl:with-param name="fieldName" select="'Link'"/>
                  </xsl:call-template>
                  -->
                                    <xsl:value-of select="concat(concat('/Tulsa/2009/Speakers/', translate(title, ' ,.','')), '/')"/>
                                </xsl:attribute>
                                <img border="1" style="border-color: black;" hspace="3" vspace="3" width="46" height="60">
                                    <xsl:attribute name="src">
                                        <xsl:text>/Tulsa/2009/SiteImages/Speakers/</xsl:text>
                                        <xsl:value-of select ="translate(title,' ,.','_')"/>
                                        <xsl:text>.jpg</xsl:text>
                                    </xsl:attribute >
                                    <xsl:attribute name="alt">
                                        <xsl:value-of select="title"/>
                                        <xsl:variable name="tagline">
                                            <xsl:call-template name="getWSSDescriptionField">
                                                <xsl:with-param name="description" select="description"/>
                                                <xsl:with-param name="fieldName" select="'Tagline'"/>
                                            </xsl:call-template>
                                        </xsl:variable>
                                        <xsl:if test="$tagline!=''">
                                            <xsl:text>, </xsl:text>
                                            <xsl:value-of select="$tagline"/>
                                        </xsl:if>
                                        <xsl:variable name="company">
                                            <xsl:call-template name="getWSSDescriptionField">
                                                <xsl:with-param name="description" select="description"/>
                                                <xsl:with-param name="fieldName" select="'Company'"/>
                                            </xsl:call-template>
                                        </xsl:variable>
                                        <xsl:if test="$company!=''">
                                            <xsl:text>, </xsl:text>
                                            <xsl:value-of select="$company"/>
                                        </xsl:if>
                                    </xsl:attribute>
                                </img>
                            </a>
                            <xsl:if test="position() mod 3 = 0">
                                <br/>
                            </xsl:if>
<!--                        </xsl:if>-->
                    </xsl:for-each>
                </td>
            </tr>
        </table>
    </xsl:template>

    <xsl:template name="string-replace-all">
        <xsl:param name="text"/>
        <xsl:param name="replace"/>
        <xsl:param name="with"/>
        <xsl:choose>
            <xsl:when test="contains($text, $replace)">
                <xsl:value-of select="substring-before($text, $replace)"/>
                <xsl:value-of select="$with"/>
                <xsl:call-template name="string-replace-all">
                    <xsl:with-param name="text" select="substring-after($text, $replace)"/>
                    <xsl:with-param name="replace" select="$replace"/>
                    <xsl:with-param name="with" select="$with"/>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="$text"/>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="getWSSDescriptionField">
        <xsl:param name="description"/>
        <xsl:param name="fieldName"/>

        <xsl:variable name="before" select="concat($fieldName,':&lt;/b&gt; ')" />
        <xsl:variable name="after" select ="'&lt;/div&gt;'" />
        <xsl:variable name="htmlFieldStart" select="'&lt;div class=ExternalClass'" />

        <xsl:variable name = "leftRemoved" >
            <xsl:value-of disable-output-escaping="yes" select="substring-after($description,$before)"/>
        </xsl:variable>
        <xsl:variable name = "results">
            <xsl:value-of disable-output-escaping="yes" select="substring-before($leftRemoved,$after)" />
        </xsl:variable>

        <!-- HTML fields have extra <div>-->
        <xsl:choose>
            <xsl:when test="starts-with($results, $htmlFieldStart)">
                <xsl:value-of disable-output-escaping="yes" select="substring-after($results,'&gt;')" />
            </xsl:when >
            <xsl:otherwise>
                <xsl:choose>
                    <xsl:when test="contains($results, '&amp;amp')">
                        <xsl:call-template name="string-replace-all">
                            <xsl:with-param name="text" select="$results"/>
                            <xsl:with-param name="replace" select="'&amp;amp;'"/>
                            <xsl:with-param name="with" select="'&amp;'"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:value-of disable-output-escaping="yes" select="$results"/>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:template>
</xsl:transform>

I’ll continue explaining more of the other sections of the site, plans for the future and more in upcoming posts!

I definitely don’t claim to be an XSLT expert. I’ve just managed to keep making it do what I need as I need to over the years. It is an excellent way to build functionality into SharePoint with no-code out of the box web parts.

Let me know if you have any questions and/or suggestions for improvements!

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Many quick updates and first XSLT sample for SharePoint ??? Event Management System - server camp

Leave a Comment

(required) 
required 
(required) 
Enter the code you see below