New here? Then you may want to subscribe to my rss feed. :)

C# and XSLT extension objects

May 14th, 2007 | Posted in .Net, Development | 1 Comment

Recently, I needed to transform an XML feed using C#. I wrote the XSLT script and it all worked ok.

One of the parts of the page took a TITLE and passed it to a Javascript function which then passed it to a flash file. This one particular record had a single quote, which as all developers know, will break everything within a 3 mile radius.

Trawling the MSDN rainforest led me to discover that you could pass parameters from the C# class which was carrying out the transformation, so I wondered if you could call methods in C# from the XSLT and behold you could.

The key was the AddExtensionObject method.

CSharp [Show Plain Code]:
  1. // Load XML document
  2. XPathDocument myXPathDoc = new XPathDocument("c:/myfile.xml") ;
  3.  
  4. // Create trans object
  5. XslCompiledTransform myXslTrans = new XslCompiledTransform() ;
  6.  
  7. StringBuilder sb = new StringBuilder();
  8. StringWriter sw = new StringWriter(sb);
  9.  
  10. //load the Xsl
  11. myXslTrans.Load("c:/myfile.xslt") ;
  12.  
  13. // Create and add XSLT extension
  14. XsltArgumentList argsList = new XsltArgumentList();
  15. myHelperObj myObj = new myHelperObj();
  16. argsList.AddExtensionObject("urn:myObj", myObj);
  17. myXslTrans.Transform(myXPathDoc,argsList, sw);

Then as part of your xsl stylesheet declaration add:

  1. <xsl :stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  2.         xmlns:myObj="urn:myObj"></xsl>

Whereas before this would throw an error:

  1. <a href="#" onclick="return callExternalInterface(’{title}’);"></a>

By adding the XSLT extension object I could now do this:

  1. <a href="#" onclick="return callExternalInterface(’{myObj:makeJsSafe(title)}’);"></a>

Discuss this article »

What makes a good web host?

May 13th, 2007 | Posted in Techy Talk | 2 Comments

A common request from colleagues and site owners is to recommend a reliable and low cost web host. My initial response was to go on location, so if you are a UK based site then going for a UK based host will provide you with a support department that’s open during your waking hours as opposed to one located in the States.

With the ever increasing number of web hosts and the improvement in reliability and support, location no longer applies.

So how do you decide?

This is difficult to answer. You ask 10 different sites and they will give you 10 different hosts. I could recommend ACME WEB HOSTS (please don’t Google them, I made them up… hang on… Yep , they don’t exist) and no doubt a quick Google search will find people who have had nothing but bad experiences with them.

My current host, who are absolutely brilliant, no down time and everything simply… works, are Slicehost. They are not for everyone as they are a Linux based VPS host. If you can brave command line Linux to get it all up and running then they are worth a look. The wiki has a wealth of information to help get you up and running and their support is near instant.

To begin with, you need to make a list of what it is your site will need. For example, If your site was built in .Net or ASP (and if it is ASP then we need to have a serious chat) then you obviously need a Windows host. Does or will it need any third party components, if it does then you need a host that already has them installed. If you cannot find one then your only option is either a Windows VPS host or, budget permitting, a dedicated server. Does it have a database? If so which? MSSQL, MySQL. Take a step back and look at your site and make a list of what it needs to function, this will help greatly in narrowing possible hosts.

Once you have a list, the next stop would be to make a short list of suitable hosts. Either by googling, asking existing site owners and developers, trawling forums such as Webhostingtalk. Finally, make a decision. Many hosts have a 15 or 30 day money back policy so if you end up with a real stinker then you can back out. Personally, I am not convinced that 15 days is enough time to get a real idea of how good a host is.

Here’s my tuppence worth:

Linux VPS host - Slicehost

Windows shared host - Titanhosts

Discuss this article »

Darkroom - A procrastinator’s dream editor

May 12th, 2007 | Posted in Bloomin' Cool, Software | 1 Comment

Sometimes, when writing proposals or posts for my blog, I find it difficult to focus and end up doing those jobs which on any other day I would have avoided like the plague. Such as mowing the lawn or catching up on my Quincy repeats.

Thanks to freelanceswitch, I have started using an editor which is an absolute god send. To the point where this is in fact my third document of the day. The editor is called DARKROOM.

What’s so good about it?

Simply, it pushes all desktop distractions into the background. When you run the program for the first time, it sizes to full screen. So all you see is a black screen with a blinking cursor. No toolbars, no system tray distractions, just a black screen and a blinking cursor. When you start typing the default text colour is green, essentially what you have is an editor with the look of a green screen terminal. Having this allows you to focus your thought process towards the document without the odd glance over to my system tray new email alerter or MSN icon.

Now when I say this is a simple editor, I mean it. Not only in looks, but features. You can only create new lines, copy, paste, save and save to text files. So you kind of are getting the picture, but when all you want to do is to get that idea down then this is ideal.

Dark room editor screenshot

Discuss this article »

The reality of working for yourself

May 12th, 2007 | Posted in Development, Freelancing | 25 Comments

I enjoy working for myself. Being my own boss and making decisions on pretty much all aspects of running a self employed business. Despite this rosy picture, there is a side which takes some getting used to. It is something which in hindsight seems really obvious.

Continue reading this article »

Discuss this article »

Web site clones

May 11th, 2007 | Posted in Funny, Techy Talk | 4 Comments

My first tentative steps into freelancing involved trawling the many project sites, bidding for potential assignments. Sites such as Getacoder and Getafreelancer were where many hours were spent until the small hours of the morning.

Many years later, I am happy to say that I no longer need to take part in the daily fought bidding wars. To put it bluntly, freelance sites like the ones mentioned are a meeting place for clients with no budget, clue and in many cases manners looking to acquire the services of developers and designers who end up with no other choice than to accept whatever is thrown at them.

Example, when I started out I bidded and won a project which was to take online betting onto handheld devices. I was several weeks in to the project when I received an email detailing why the client suddenly needed to back out. Apparently, he was being threatened by the Columbian mafia and he could no longer continue with the project. He claimed that they were developing something similar and did not want the competition. Needless to say, I never heard from him again and I was out of pocket. Lesson learnt.

I realise there maybe genuine projects posted but they are few and far between.

Not only that, but they have become a source of ridicule, especially when cloning sites is concerned. Barely a day goes by when a project is posted asking for an “Ebay Clone” with a budget of $300. Simply, a clone is a complete copy of the site in question. So for $300 the person wanted a complete copy of Ebay with all its features. I kid you not.

See for yourself, visit www.getafreelancer.com and do a search for “clone”. Last I checked, there was a YouTube clone where the highest bid was $36.

Discuss this article »