January 2008 - Posts

What's broken?  It would appear that there are a couple of problems with consuming Atom feeds using the RSSToolkit.

  1. <pubDate/> shows up empty
  2. <link/> use the the base URL for the channel instead of the URL for each <item/>

I opened up a work item for these issues, and here's what fixed it for me:

  • Download the Source.
  • Open the Resources\AtomToRSS20.xsl file and make the following changes:
    • LINE 25: <xsl:value-of select="//*[name()='modified']"/> should be <xsl:value-of select="//*[name()='updated']"/>
    • LINE 43: <xsl:value-of select="//*[name()='link']/@href"/> should be <xsl:value-of select="child::*[name()='link']/@href"/>
    • LINE 55: <xsl:value-of select="//*[name()='modified']"/> should be ><xsl:value-of select="child::*[name()='updated']"/> *updated 2/1/2008
    • Recompile the .DLL file. Or, I uploaded my recompiled version with the work item.

Follow my erotic tale of "code awakening" as I discover AJAX's raw naked self.  We'll pop the hood and see AJAX as nature intended. This steamy tale of passion, romance, love, and AJAX may leave you breathless and panting for more. Or, it could simply be a ruse to get you to read my article. I'm not above shameless marketing tactics.  Sex sells and you're buying... ;-)

 

"Wam-Bam" AJAX

The following example is not valid, has no error checking, is messy, but it will work in IE7, Firefox, Opera, and Safari. It is the least amount of effort (I think) needed to demonstrate AJAX.  We will use two files for this example to show that a basic html page can pull information from a separate file on the server. No gender roles are defined for either of these files so, just pick your pleasure, open your imagination, and read on...

Content.txt

You're hot!

Default.html

<script type="text/javascript">
        var xmlHttp = null;                
        window.onload = function() {
            xmlHttp = new XMLHttpRequest();
            xmlHttp.open("GET", "Content.txt", true);
            xmlHttp.onreadystatechange = onCallback;
            xmlHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
            xmlHttp.send(null);            
        }        
        function onCallback() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.status == 200) {
                    alert(xmlHttp.responseText);
                }
            }
        }
    </script>

What's this do?

As Default.html loads in the browser, the JavaScript creates a new HTMLHTTPRequest and then uses it to retrieve the contents of the text file from the server. The results are displayed in an alert box. It sure doesn't feel like the warm snuggly AJAX we're looking for, but it's a nice little piece of AJAX to peak our interest.

 

"Second Date" AJAX

Okay. We got "the deed" done in the first example, but this little quickie just won't cut if we're serious about this little trist. Let's turn the lights on and get a better look at the example in a valid HTML page, with some basic error checking, and a few comments so we know what we are dealing with.

Content.txt

You're hot AND thoughtful!

Default.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>AJAX Example</title>
    <script type="text/javascript">
        var xmlHttp = null;
        
        window.onload = function() { // Begin the request when page loads
            loadXmlHttp(); 
            sendRequest("Content.txt")            
        }
        
        function loadXmlHttp() {
            // Do a little browser detection to see if we can
            // use XMLHTTPRequest or if we are stuck w/ the ActiveX
            // option.
            if (window.XMLHttpRequest) { //IE7, Mozilla, Safari, Opera
                xmlHttp = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                try{
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // IE5 & 6
                }
                catch(e) {}
            }
        }
        
        function sendRequest(url) {
            if (xmlHttp) {
                xmlHttp.open("GET", url, true); // "true" creates an async. request
                xmlHttp.onreadystatechange = onCallback;
                xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                xmlHttp.send(null);
            }
        }
        
        function onCallback() {
            // This function will run over and over as the request 
            // goes though processing
            if (xmlHttp.readyState == 4) { // "4" indicates the end of the request
                if (xmlHttp.status == 200) {// "200" indicates a successful request
                    alert(xmlHttp.responseText); //Display the result
                }
                else { //Something went wrong.
                    alert('Error: ' + xmlHttp.status);
                }
            }
        }
    </script>
</head>
<body></body>
</html>

What's this do?

Basically, we took a "drunken one-night stand" of an example, and took it out for dinner.  The output is the same, but you can see that we are being a little more careful by loading the correct request object and checking to see if the request was successful. It's still pretty shallow and not something worth committing to, but it's starting to get interesting.

 

"Falling in Love" w/ AJAX

Now that we have the mechanics down, we can get a little adventurous and begin to spice things up. Let's add some of that hot AJAX interactiveness everyone's talking about and see what happens.  For this example, we will ask a question on the HTML page, wait for a response, and then see the response from the text file without any of that flacid postback action. The juicy bits have been highlighted in the code for your veiwing pleasure.

Content.txt

Of course I love you, AJAX!

Default.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>AJAX Example</title>
    <script type="text/javascript">
        var xmlHttp = null;
        
        function askBigQuestion() {
            var l = document.getElementById('Loading'); // Find the loading object
            l.innerHTML = "I'm thinking..."; // Display some feedback during the process
            loadXmlHttp(); 
            sendRequest("Content.txt")            
        }
        
        function loadXmlHttp() {
            // Do a little browser detection to see if we can
            // use XMLHTTPRequest or if we are stuck w/ the ActiveX
            // option.
            if (window.XMLHttpRequest) { //IE7, Mozilla, Safari, Opera
                xmlHttp = new XMLHttpRequest();
            } else if (window.ActiveXObject) {
                try{
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); // IE5 & 6
                }
                catch(e) {}
            }
        }
        
        function sendRequest(url) {
            if (xmlHttp) {
                xmlHttp.open("GET", url, true); // "true" creates an async. request
                xmlHttp.onreadystatechange = onCallback;
                xmlHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                xmlHttp.send(null);
            }
        }
        
        function onCallback() {
            // This function will run over and over as the request 
            // goes though processing
            if (xmlHttp.readyState == 4) { // "4" indicates the end of the request
                if (xmlHttp.status == 200) {// "200" indicates a successful request
                    var r =document.getElementById('Result');
                    r.innerHTML = xmlHttp.responseText; // Display the result
                    var l = document.getElementById('Loading');
                    l.innerHTML = ''; // Clear the feedback
                }
                else { //Something went wrong.
                    alert('Error: ' + xmlHttp.status);
                }
            }
        }
    </script>
</head>
<body>
    Do you love me?
    <input type="button" onclick="askBigQuestion();" value="Ask"/>
    <br /><br />
    <span id="Loading"></span>
    <span id="Result"></span>
</body>
</html>

What's this do?

When the user clicks on the button, the request begins, a status message is displayed while the request is processed, and then the contents of the text file are rendered on the page. Hmmm...maybe not as sexy as we were hoping for, but the potential is definitely there for some very hot action.

 

The "Big Commitment"

It's decision time. How much farther do we want to go with this AJAX thing?  After this point, it's a big commitment (at least for me) to learn more JavaScript, understand the DOM, meet the relatives (JSON, REST, SOAP, etc), and a whole host of other freaky-deaky things. 

Personally, I am not ready for a full on commitment just yet. I am just going to finish reading my new book that I won from Dave Ward on his blog, "ASP.NET AJAX in Action" so I know how my "AJAX framework de jour" really works. Other than that, I'll and keep "playing the field" with some other technologies I've been flirting with--I'm such a tech whore--and let the smart people keep creating great frameworks that are so easy, even I can use them. 

Whew...I don't know about you, but I need a nap...

It's the burning question that's been haunting me for years.  Where did this little ambiguous icon come from? What was the inspiration for this symbol of information subscription? What great mind dove deep into their soul and returned with this gem?

I may have uncovered the mystery...See it for yourself.

I attended last year and, though a bit on the spendy side, it was a worthwhile trip and will probably be attending this year as well. Here are some tips if you've never been to this event at the Orlando, Florida location.

  • The hotel is ginormous. Not just big, ginormous. Plan on getting lost a few times. The size of the resort and the conference rooms is truly amazing.
     
  • The hotel is not within walking distance of any other restaurants, bars, clubs, stores, etc.  Unless you have a car or are willing to spend $30 minimum to go somewhere by taxi, plan on being in the hotel the entire time.  Naturally, prices at the hotel's restaurants, bars, and convenience store reflect this lack of external choices. Take advantage of the meals provided by the conference so you can splurge in the hotel restaurants at night.
     
  • You might be cold the entire time. "Cold", you ask? Yes, cold. My room was set to 64 degrees when I arrived and the conference rooms seemed about the same. Like most venues I've been to where the outside climate is hot, the A/C is always pumping. If you are used to this, great.  If you come from a drier, colder climate. As dumb as it sounds, you'll may want a coat or something to keep you warm in...Orlando.
     
  • BYOPS (bring your own power strip). Outlets are scarce. There is always a scramble to find a plug before each session and during breaks.  "Would you like to share my power strip?", would make an excellent pickup line and could perhaps net you some evening entertainment. ;-)
     
  • Bring a long ethernet cable.  The room only has a 6' cable and they won't bring you a longer one.
     
  • There was no Internet access in the conference rooms, but you could get onto the hotel wireless in the lobby area if you purchased Internet access for the day. Get the "World Pass" if you are going to buy Internet access. It's $2 more a day but you get some perks including free use of the driving range.
     
  • The resort is rated "5-star", but due to the size and volume of guests, they simply can't provide a real "5-star" experience. Room cleaning was hit and miss. Odd things like sometimes I had coffee, and sometimes I didn't. There is always a lot of noise--construction, guests, cleaning, etc.--not very peaceful.  Checkout was at 11am but they were banging on my door at 9:30 wanting to know when I would be leaving.  I opened the door and said, "I will be leaving after I finish my shower and get my clothes on."--yeah, that's how I roll.
     
  • The TV in the room did not have any auxiliary A/V inputs.
     
  • When you're not at the conference, unless you have a car, entertainment choices are limited--especially if you are by yourself.  There's golf, but only until dark.  There's tennis (contact me if you're interested in playing some evening). There's a nice 24-hour fitness center. There's the expensive hotel bars.
     
  • The dirty little secret--Parking.  Parking in the parking center will run you $10.65 a day and is a long hike to and from the hotel. I think there might be a shuttle (yeah, it's that far), but don't quote me. Someone could probably make some money as a suitcase Sherpa at this hotel if they were so inclined.  Valet parking is $19.17 a day.
     
  • DISCLAIMER: I don't know if this is allowed/legal or not, so don't do this if it's not.
    You get resource discs for the track that you pick (SQL, ASP.net, etc).  You don't get discs for the tracks you are not in--even though you can attend sessions from any track you want. I don't know why this is but it not very nice. So, find people who are in other tracks and rip their discs before the end of the convention. There was a lot of this going on, but again, read my disclaimer.  If you are traveling with a group, get everyone in different tracks so you don't all get the same resources.

Bottom line...

While I don't really like the venue, I prefer it over Las Vegas.  The sessions are "meaty" and the workshops are even "meatier".  Lots of developers and lots of opportunities to meet others.

This MS Word Document flyer sums it up, but it looks like Verio is providing free web hosting for members of Microsoft User Groups through January 2010.  These are regional groups that regularly meet and are a great resource if you have one near you.

The hosting plan is a little limited (100mb disk space + 20mb SQL), but for the price of $FREE it's more than generous.  To get signed up, find yourself a User Group to join and attend the next meeting.  At the meeting ask for the form, fill it out, and send it to your User Group leader.
 

Yahoo! has released an API that allow you to easily embed a media play that will automatically attach itself to MP3 links.  They had one that just linked to their own music library, but that's boring.

 

Here is a sample HTML page that has some MP3 links and an embedded audio player:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My MP3 Page</title> <script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script> </head> <body> <a href="http://podcastdownload.npr.org/anon.npr-podcasts/podcast/510008/17999726/npr_17999726.mp3?dl=1">NPR Podcast</a>
</body> </html>

 

Here's how it will render (Click the play icon):

NPR Podcast

When the play button is clicked, a media player will appear and the file will play in a pop-in media player.  It's nice because you have a good deal of control over the player just by changing the hyperlink.  It uses semantic HTML and an independent JavaScript file.

I wouldn't mind seeing more APIs that follow this type of implementation.  I know it puts a 3rd party in between you and the client, but so do things like PDFs and Flash.

More Posts