Nik's Technology Blog

Travels through programming, networks, and computers

View Output of an XSLT Transformation using Firefox

XSLT is a powerful method of converting XML into another well-formed XML based document. You can for example transform RSS syndication format into ATOM and even XML into XHTML.

Probably the easiest way to debug your XSLT is to use the Firefox web browser. Make sure you have the Web Developer toolbar (by Chris Pederick) installed.

You'll need to add a stylesheet to the XML document you're transforming using a declaration like this:


<?xml version='1.0' encoding='UTF-8'?>
<?xml-stylesheet type="text/xsl" href="transformAtomFormat.xsl"?>

Then in Windows Explorer right-click the XML document and open in Firefox. You'll see the rendered output of your transformation in the browser. If you view the page source you'll see your XML source, not much use when you want to see the output source of your XSLT transformation. For this you need to right click somewhere on the page, find the Web Deveoper toolbar menu and choose "View Generated Source" from the sub-menu. Now you'll see what Firefox is rendering to the screen.

Find out more about XSLT at W3 Schools

Google Reader 'Shared Items' Widget Broke My Site in IE7

As an avid user of Firefox the dangers of using one browser (apart from initial testing) became apparent today, especially considering most web users still use Internet Explorer.

I recently converted my site to use Blogger, and I also thought I'd share interesting news articles I read with my visitors by using Google Reader's Javascript widget.

Google Reader is still in Beta

I placed the Javascript widget on my home page and my blog pages a while back. I just checked my site in Internet Explorer 7 and was amazed to see only the template was rendered. There was a distinct lack of content!

I looked at the source HTML, and the content was there. I was puzzled for a few minutes until I realised what the blog page and the home page had in common; The Javascript Google widget.

I quickly removed them and FTPed the pages, the problem was resolved. I grabbed the URL the script block was trying to call and tried to download the external Javascript straight to my browser... it timed-out.

It appears that Internet Explorer will get stuck when external Javascript doesn't load, so be aware of this the next time you choose to use an externally hosted Javascript file. Opera and Firefox didn't seem to have a problem.

A Recipe for a Successful Website

Creating a successful website can be a hit and miss affair even before you've even thought about attracting users to the site.

There are countless websites, books and consultants dedicated to designing websites, web programming and development, search engine optimisation, usability and accessibility. However even if you have an expert specialising in each field on your development team you will have to make difficult decisions along the way which can have a fundamental impact on how your site will perform. This won't be much of a surprise to anyone in the business.

Web Designers Role

Web designers for instance need to be able to create designs that have a high level of usability as well as creating a visually appealing design that sticks to standard methods of navigation with a colour scheme that conforms to accessibility guidelines. Good guidelines and specifications are needed from the client and the other members of the team prior to commencing work so the designer knows the scope of the project.

Web Developers Role

Web developers need to be aware of search engine optimisation techniques and accessibility practices while building pages based on the chosen design. The choice of development environment is also important. Will your website scale when your users increase? Will your choice of platform and IDE have negative impacts on your SEO and usability efforts? Dreamweaver and other WYSIWIG editors are renound for adding reams of unnecessary HTML to your pages. Visual Studio's standard web controls also introduce problems with large VIEWSTATE tags and lots of pointless nested tables.

Search Engine Marketers Role

Search engine marketers need to make sure that they stick to "White Hat" methodoligies. They will need to have an intimate understanding of your business or product(s) in order perform keyword research.
In the push to get goods search rankings usability can be affected by excessive keyword stuffing, which can make paragraphs of text un-readble.

Usability and Website Testing

While usability evangelists will restrain the designers and developers from using browser plug-in technologies and any form of cutting edge design, or navigational elements that deviate from what Web users' expect. Badly positioned advertisements can also affect the usability of the site especially the flash pop-out kind.

The Client

If the client insists on items of functionality and design that will have a detrimental effect on the site such as using a splash page, a non-standard navigation tool etc, he or she will need to be educated on the impact of implementing such items.

Lots of websites fail to look at website development from one or more of these view points and suffer one way or another. Whether that is through confusing users with un-navigable sites, failing to generate traffic because of poor search engine optimisation or making people install software to view your content.

Creating a successful website requires a lot of different skill sets, but this will depend partly on your audience and your individual goals for the project.

An Overview of the ASP.NET Cache Object

I've been looking at the ASP.NET cache object, which makes the older Application object effectively redundant. The analogy is that it is like a leaky bucket. A bucket in which you can store data which is "expensive" to retrieve from its source every time. Since databases and files are considered slow in comparison with in-memory data then it makes sense to keep a copy of certain data you use frequently in the cache, which is stored in memory.
The bucket is leaky because you can only put so much data in the cache before it fills up and has to drop some. It uses a simple method called LRU - Least Recently Used to decide what data it disposes of by default. I say by default, because you can specify, if you so wish and make data persist for a period of time or make it dependent on other data on file, database, or cached data.

The cache is shared however by the whole application and is therefore accessible by the whole application, so you have to be careful what kind on data you store in here. You probably don't want to store user specific data here!
You also need to check that the data you want to use is in the cache before you go and use it. Sounds obvious, but if you don't code this right, by assigning the cached object to a variable then checking the variable you could discover bugs which you can't replicate in a test environment.

Data Layer with Business Logic

Deciding when to move business logic to the data layer in a multi-tiered application is a tricky one and depends a lot on the RDMS you are using.
I've been looking at an ASP.NET application that creates 7 rows in a database for each "musical performance" when a button is clicked on a web form to rebuild a database.
To begin with a SQL 2005 stored procedure written in VB.NET (But could easily have been C# with the same results since all .NET languages are compiled to IL). was called from a loop in the business layer 7 times to create the 7 rows. The application was run and it took about 90 seconds to rebuild a test database in this manner.

This logic was then moved into 1 stored procedure still written in VB.NET; The result was that instead of making 7 calls to the database each time, we make 1 call to the database and move the business logic, executing the loop there, and hence at the data layer. The database rebuild took about 30 seconds this time.

Stored Procedures in Native T-SQL

To try and make the execution faster we decided to write the stored procedure in T-SQL, which is still the native language of SQL Server. This shaved another 15 seconds of the execution time! Just proving what sort of overhead writing your stored procedures in anything other than T-SQL introduces.

This exercise provides a glimpse into how the decisions you make when designing an application radically affect the responsiveness of the system.

Business Logic at the Data Layer

If you were pulling lots of data to the business layer performing some processing then discarding most of the data at that point, then it may improve performance if this operation was moved down to the data layer. It really depends on the data and the application.
One of the problems with storing too much application logic in the data layer is version control. It can become a mine field managing lots of complex stored procedures between test and live environments and keeping them in-sync with the application.

The Rel Attribute in HTML

The rel attribute is available for use in a few HTML tags namely the <link> and <a> anchor tags, but until recently it has been fairly pointless to use because web browsers did not support the intended functionality of most of the values you could assign to the rel attribute.

The rel attribute has been around since HTML 3 specifications and defines the relationship between the current document and the document specified in the href attribute of the same tag. If the href attribute is missing from the tag, the rel attribute is ignored.

For example:
<link rel="stylesheet" href="styles.css">

In this example the rel attribute specifies that the href attribute contains the stylesheet for the current document.
This is probably the only recognised and supported use of the rel attribute by modern web browsers and by far the most common use for it to date.
There are other semantic uses for the rel tag, beyond those which a browser might find useful; such examples include social networking, and understanding relationships between people; see http://gmpg.org/xfn/intro, the other use which has been talked a lot about recently concerns search engine spiders.

Search Engines and the rel Attribute

Recently Google has played a big part in finding another use for the rel attribute. This time the HTML tag in question was the humble anchor tag.
Google and the other major search engines (MSN and Yahoo!) have a constant battle with SERP SPAM which clutter their results and make them less useful. These pages make their way into the top results pages by using black hat SEO methods such as automated comment SPAM, link farms etc.
Rather than adopt a complex algorithm to determine these SPAM links which increase target pages search engine vote sometimes called "Page Rank" or "Web Rank", the search engines (Google, MSN and Yahoo!) have collectively decided that if blogging software, big directories and general links pages etc use anchor tags with a rel="nofollow" attribute those links will simply be ignored by search engine spiders, yet still be fully functional for end users.
Of course using rel="nofollow" does not mean the links are deemed as bad in any way, every link on a blog comment will be treated in the same fashion. The webmaster is essentially saying

"this link was not put here by me, so ignore it and do not pass any "link juice" on to it".

More on nofollow by Search Engine Watch.

Putting Webmasters in Control

Putting this kind of control in the webmasters hands hasn't been without controversy. People will always try to experiment with ways of manipulating the intended outcome to favour their own goals, such as using nofollow internally in their site etc. Others have welcomed the move as a way of reducing the problem of spamming.

ASP.NET Web Accessibility and Visual Studio 2005

I've been using Visual Studio 2005 on a recent project and was surprised that even though it is supposed to feature lots of web accessiblity tools and options, they don't seem to be turned on by default. I'll bring you an example to back this up.
I created a new ASP.NET page, essentially it was a simple form, which when submitted sent an email; similar to a contact form if you like. The form was built within an HTML table, with ASP:Label controls to hold the textbox definitions.
On viewing the page in a browser and examining the source code, I noticed that the ASP:Label controls are converted to HTML <span> tags, which is a little bizarre. After a little research I found that if you use the AssociatedControlID property of the ASP:Label to link to the related textbox the HTML source code produced now uses an HTML <label> tag.
I also figured out that using the ToolTip property of the ASP:Label control renders as the title property of the HTML label tag.

So the following ASP.NET source code:

<asp:Label ID="LblDayMovedOut" runat="server" ToolTip="Day Moved Out" AssociatedControlID="DayMovedOut">
<asp:DropDownList ID="DayMovedOut" runat="server"></asp:DropDownList>
</asp:Label>
<asp:Label ID="LblMonthMovedOut" runat="server" ToolTip="Month Moved Out" AssociatedControlID="MonthMovedOut">
<asp:DropDownList ID="MonthMovedOut" runat="server"></asp:DropDownList>
</asp:Label>
<asp:Label ID="LblYearMovedOut" runat="server" ToolTip="Year Moved Out" AssociatedControlID="YearMovedOut">
<asp:DropDownList ID="YearMovedOut" runat="server"></asp:DropDownList>
</asp:Label>


Would render the following bloated, but accessible HTML:

<label for="ctl00_ContentPLaceHolder_DayMovedOut" id="ctl00_ContentPLaceHolder_LblDayMovedOut" title="Day Moved Out">
<select name="ctl00$ContentPLaceHolder$DayMovedOut" id="ctl00_ContentPLaceHolder_DayMovedOut">
</select>
</label>
<label for="ctl00_ContentPLaceHolder_MonthMovedOut" id="ctl00_ContentPLaceHolder_LblMonthMovedOut" title="Month Moved Out">
<select name="ctl00$ContentPLaceHolder$MonthMovedOut" id="ctl00_ContentPLaceHolder_MonthMovedOut">
</select>
</label>
<label for="ctl00_ContentPLaceHolder_YearMovedOut" id="ctl00_ContentPLaceHolder_LblYearMovedOut" title="Year Moved Out">
<select name="ctl00$ContentPLaceHolder$YearMovedOut" id="ctl00_ContentPLaceHolder_YearMovedOut">
</select>
</label>

Adsense and Amazon's New Context Links Beta

I received an email from Amazon Associates yesterday explaining their contextual adverts are now out of closed beta and are now available for their associates to use (although still in beta).

I checked out the demo sites they mentioned, looked at the source HTML and logged into the Associates homepage to see what customisations were available.

All it requires is a few Javascript includes at the foot of the page and all the rendering is done client-side. Essentially any word(s) on your page can be linked to Amazon or Amazon Marketplace items, and they're all relevant!

No More Manual Links!

Hold your horses! Those of you who are Adsense publishers beware! I have been reading Adsense terms and conditions and some blog posts and I'm pretty sure you can't use Adsense and Amazon Context Links ads on the same page.

Does anyone have Google's official stance on this?

What about Amazon's terms and conditions? Do they have similar terms concerning competitor contextual ads?

At the end of the day, you can't blame Google from wanting to hold on to it's huge Adsense publisher network.

Contact forms, SPAM relay email and the CAPTCHA

Back in January this year I decided enough-was-enough with increasing amounts of automated SPAM coming into my inbox and originating from my site. I decided to do something about it. My contact form has been attracting lots of SPAM bots which were trying their best to relay their SPAM through my site.

My form has always had the To: and From: fields hard-coded however, so I doubt anything ever got relayed, but they all got sent to me anyhow.

As a result I now verify that the form was actually filled in my a HUMAN each time the form gets sent! I've built an ASP CAPTCHA function to achieve this (Completely Automated Public Turing test to tell Computers and Humans Apart), more about CAPTCHAs here.

Accessibility and CAPTCHAs

There are however down-sides to this SPAM free existence. CAPTCHA images in the form that I am using are inherently inaccessible, so I intend to use another system in conjunction with my image CAPTCHA as used my Matt Cutts on his blog.

Recruiting Web Developers - Finding the right coder!

I've had a fair bit of experience employing web developers in recent years, I've also read a fair number of CVs, and posted a number of online adverts.

With recent changes to UK employment law it's more difficult than ever to attract the right candidates and get them to apply, as well as successfully convince the wannabe developers that a particular post isn't for them.

I've read a couple of articles today that interested me concerning recruitment. This article about writing a resume for developers shared some useful tips about writing CVs, most of which I can definitely recommend judging by the CVs I receive.

The second article I read, (but can't find the link!) talks about a novel way of advertising for web developers, advertise in your HTML source code of course! Only developers would look there of course, so you're audience, however small, is highly targeted.

I'd like to add to the list of what not to do while trying to secure an interview:

  • Don't SPAM companies with your CV - once is plenty for each position
  • Don't include SPAM/holding domains/dodgy sex domains on your CV unless you're applying for a job in this area
  • Do we really need to know what your late Father's name was?
  • Your National Insurance number is not necessary - haven't you heard of ID theft?
  • Weird lists of hobbies which are unrelated to the job you're applying for
  • Any lack of formatting, mixtures of fonts, font sizes, colours
  • Is a photo of you really necessary?