Friday, 27 June 2008

XSLT

After spending so much time generating my XML data I decided that I wanted to be able to see it presented in a user friendly fashion. Enter XML Stylesheets.

Boy what a frustrating time I had getting these to work. I found two big problems that took some time to solve.

The first problem that I had was originally the browser complained about my stylesheet because the web server reported its mimetype as text/xml and suggested it should be text/css. I reconfigured the webserver thinking this was the problem (of no output) but found that the browser then tried to interpret my XML stylesheet as CSS and produces a multitude of errors as a result.

So after changing it back (and still not working) I finally hit upon the solution. The web server has to report the file as text/xml but the source XML file has to tell the browser that it is text/xsl so the browser knows how to interpret it.

Secondly, I found that although I wrote a valid stylesheet for reasons that I couldn't fathom it produced either no output or wrong output. The browser will only complain at you when your stylesheet is not valid or well formed but if it passes these two tests there is no way to ask it what is wrong with the stylesheet.

So then I had to start with the most basic stylesheet and work my way up from there. One of the things that caught me out was the matching system. If for some reason your templates didn't match everything in the XML file the the browser would just dump any XML that was left over. This was a huge source of frustration as I had the impression that anything not matched would be ignored.

I did finally get a reasonablly working stylesheet:

https://netdb.alphawest.com.au/xml/netdb-style.xsl

Now it is a simply task as I add a new node to the XML output to create a new template into the stylesheet and get it parsed as the appropriate place. Simple now that it works!

XML and Schemas

I have embarked upon a project to output XML data from my intranet application. For what end I don't know yet but I thought it would be a useful exercise to have the ability to have my data in XML format.

My first attempt was the usual ad hoc method of simply outputting some XML but as I progressed I realized that I had no clear picture of what the XML should look like.

So this time around I have started with the other end and begun developing an XML schema.

https://netdb.alphawest.com.au/xml/netdb.xsd

I have done this with the assistance of Eclipse which has a nice GUI based tool for generating XML Schema. I now understand how it all hangs together and thus now have a nicely structured schema file describing what the XML form of my data should look like.

It has now become a much easier task to write the PHP code to output XML that complies with the schema. I have yet worked out a method to validate my generated XML against the schema without paying for software. Perhaps someone can recommend something.

My lesson learned from this experience is it pays to design your data first.

The next challenge is to find a useful application of this XML data. I would love to do some semantic web stuff with it but it tends to require RDF formatted data which would throw out the schema and probably require instead an OWL file describing what triples can exist.

I'll keep you posted on that.

Monday, 2 June 2008

The wonderful world of XSD

I have decided that for reasons that I don't yet understand, I am delving into the world of XML Schemas. From starting out thinking it's a relatively easy thing to describe your data to realizing what a huge task it is, I am now getting the hang of this and hopefully will be able to move on up to OWL once I am done here.

Understanding you data is the first task in creating a good schema definition. I have a standard relational database where I store all the information for my intranet web application. Sounds simply so far. Things start to get complicated when I mention that the database is actually an object relational one and yes I have tables that are inherited from other tables. Then most of these tables are represented at the middleware level by a bunch of PHP classes all inherited from a single parent.

With me so far? So from all that I want to create a schema that describes all the data that I have. Except that not all the data exists in the database and the data fakes some heirarchical information that has to now be represented in XML.

So, as you can guess, I'm having fun so far. I have an idea of the size of the task now and realize that I must spend some time making the right choices so that I end up with a useful and complete model of my data.

Wish me luck.

Wednesday, 19 March 2008

Apache SSL on Solaris

Ok, this is not a how to but a caveat. I downloaded Apache 2.2.8 onto my Solaris 9 box with the intention of upgrading from 2.0.47 and also enabling SSL. The upgrade part went fine after I managed to work out that to enable mod_ssl you need to provide two options to ./configure those being:

$ ./configure --enable-ssl --with-ssl=/usr/local/ssl

Or wherever your ssl is located. That took me a while as previously there was just the one option.

Secondly, (and this was a hard one) after installing the new apache I could not get SSL to work. On startup apache logged that it had loaded mod_ssl and generated some keys but it would not listen on port 443. I had a clue when I removed the Listen 80 statement for normal web traffic. This made apache complain that there were no ports to listen on. Ahh, it was ignoring my ssl config (contained in ssl.conf). That config was encased in a tag which it turns out was invalid (perhaps hangover from previous ssl config). Commenting it out (and the closing tag) made everything work after fixing a few more errrors.

So I guess the lesson to be learned here is that we shouldn't trust the config from the previous version of software. Too many assumptions are being made. I also don't understand why the ssl.conf file was conditionally included depending on the presense of the mod_ssl module yet the ssl.conf file had another conditional (which turned out to be broken). Why the double checking?

Oh well, at least it works now.

Wednesday, 20 February 2008

Feels good to be on the blu side

In case you haven't heard, HD-DVD is dead. Toshiba have officially pulled the plug. Some may want to cling onto their players but without any new content it will be a lonely ride.

Having just gotten a PS3 (for the games) it feels good to be on the winning side either way. From the beginning I was hoping that blu-ray would win, it just seemed like the better thought out design.

Either way, the deed is done and we can all look forward to every dvd we know being rereleased on blu-ray. Yay.

Thursday, 6 September 2007

Squid and IPv6

As it turns out if you want to have IPv6 support in the popular web proxy squid then you need to be using the cutting edge code available via CVS. This of course means that you are trying to get working code that others are still working on. Not the best situation but I'm hoping that I can get around anything that is still broken.

So far I have found a dependance on uudecode (for the icons). Of course uudecode is no longer distributed with Fedora. You only get a program called uudeview which I can only assume has the same calling semantics as uudecode. Here's hoping because currently the icons extraction doesn't work and therefore the make install doesn't working. So I am now manually trawling through the code doing manual makes where ever I think they are needed to get around this.

Getting closer.

Tuesday, 28 August 2007

IPv6 Proxy

Finally squid has been updated to work with IPv6. I am now in the process of testing this out. This is the ultimate solution to getting IPv6 working within your network. The proxy can work out the correct type of connection required and thus provide transparent access to either IPv4 or IPv6 hosts that it services.

Currently, anytime I wish to access an IPv6 site I have to disable my proxy because it doesn't understand. This is a pain and deflates my experience of IPv6. Now that squid supports IPv6 I will be able to leave my proxy on and leave the choice of protocol to the proxy depending on what type of address records it gets back from DNS.

So here's hoping I can get the beta of squid 3.x working with IPv6 support.

Monday, 6 August 2007

Grrr, ie Sucks!

Can someone who actually develops and uses IE fix it!!

When I do a shortcut to load a URL I would really just like to type it straight into the location bar. Why the need for a separate box? And when I inevitably make a mistake in the typing of said URL please don't make me reach for the mouse to click to correct it. Why can't I just hit my shortcut again and fix the few characters that I mistyped?

This is something where firefox has got it right. Keeping it simple. No wonder it is stealing market share from IE.

Anyway that's my gripe for the day.

Tuesday, 8 May 2007

Grrr, Debuggin SOAP and PHP

I don't know about you but something shouldn't be this hard. I'm currently trying to get my final SOAP code working and for the life of me I can't figure it out. The PHP module reports useless errors like "Whoops looks like we got not XML" or words to that effect.

Which means diddily squat to me. Do you know what that means? If you do can you let me know? All my other SOAP interactions work fine but the server side is running on a linux machines with the lastest updates for the PHP and SOAP code.

This last one is running on a hand compiled apache install running on solaris. I'm sure there are many areas of danger there.

So I'm stuck with this. I guess I should download and compile all the latest patches and see where that ends up.

The frustrating thing about all this is the SoapClient can understand my WSDL file present the list of functions available but cannot for reasons unknown call any of them!

I'm sure I will eventually find a solution but seriously, get some useful error messages guys!

Monday, 27 November 2006

XMPP Federation

What the? I hear you ask. No it's not some new techno-bable...well ok perhaps it is, but it's very very cool. Geek cool that is.

XMPP is a protocol for doing instant messaging. Ok that's cool. But it's also based on XML. Yep that's cool too. Better still, it is the protocol used by Google Talk which if I can be honest, is also cool.

I decided some time ago to run my own XMPP chat server. Mainly to keep company communications within the company and to allow tie in of cool things like monitoring alerts into the system.

I have that working fine but something that my system couldn't do was communicate with the outside world.

Until now.

I have managed (though I don't know exactly how) to get XMPP federation working which is the method where different XMPP servers can talk to each other.

This means my internal account can now talk to my google account and vice versa. This means I can take advantage of the fact that Google has enabled chatting from within the gmail webpage. Thus whilst checking my gmail I can also chat with work colleages which is a funky thing.

Well, ok it's also another instance of work tying me down and stuff but it's still handly to be able to communicate like that. IF I'm off at a client site perhaps and can't (for some reason) log into my internal chat service, I can just chat to work people via Google Talk.

Pretty cool if you ask me. But you probably won't, so that's ok.

Friday, 17 November 2006

Dynamic SVG

Further to my earlier post about SVG I have now managed to get a dynamic SVG image happening. My eventual plan is to have a psudo real-time graph of network load displayed in a pretty dial format.

To check it out here. Be warned you need a SVG enabled browser such as Firefox or IE with the Adobe SVG plugin installed.

The image is built up of a few basic items (the circle and the legend up the top left). All the rest of the image is created dynamically using javascript. I am now almost at the stage of getting AJAX working with this by having the page fetch network load figures from another script (written in PHP) and using those figures to update the two needles on the dial.

So far I'm impressed about how its come together. I wouldn't say it's easy but it's certainly been easier the more I learn about both SVG and javascript.

Probably the only issue that I have come up against so far is that javascript won't allow the AJAX code to pull data from a different domain that the one the original page was pulled from. This means I need an extra step to pull data from my SNMP gateway (generating the network load figures) through to the website that the SVG graph is hosted on. Once I have that figured I will have a handy almost real-time graph that shows the network bandwidth for any port I choose to point it it.

Since there is no built-in way to measure the bandwidth usage on a Cisco device, I need to take two measurements of the total octets so far and subtract them giving an octet rate which I can then run through a formula to give utilization.

So far I like the combination of technology here. I am using AJAX with SVG to create a dynamic image of network load. Later I will be using SOAP to take the network load information from the SNMP gateway through to the website.

Yet through all this I have achieved my aim of pulling together information from multiple sources into a single simple interface.

More news next time!

Tuesday, 14 November 2006

SVG Joy Part 1

My latest project has involved the funky image technology, SVG.

SVG, for those uneducated out there, stands for Scalable Vector Graphics. Perhaps you are already familiar with vector graphics? Programs out there like Corel Draw and Visio use vector graphics to enable drawings that scale to any resolution.

SVG is a technology that allows the use of vector graphics in all sorts of place such as web browsers and even desktop icons.

SVG allows funky things like animation and scripting with javascript which means making funky images that animate is now available to all of us that never learned flash!

So thus I have been playing with SVG trying to get something working that could use as a network bandwidth meter (similar to Cisco OpenWorks if anyone has seen that).

So far I don't have much but it's a start.

The concept I am working with is to create a graph similar to a cars speedo in SVG and then use javascript to update the needle according to a particular network switches bandwidth usage. So far I have managed to only get a ring of boxes drawn and even that was tricky.

I am using firefox 2.0 and it turns out that if you do something wrong in javascript it will just stop executing and not report any errors at all. Which makes debugging very difficult. But I eventually got there to the result you can see down that link. The link should work in firefox 2.0 or IE 7.0 both of which have basic SVG support built in.

I will keep you updated on how it all goes.

Friday, 10 November 2006

SOAP

I've been a bit of a slow convert over to the world of XML and specifically SOAP. I've never been one to be on the wave of a trend as it sweeps the world be it fashion or techie stuff. So it's only now that I've started playing with SOAP and all the fun things that it can do.

This is mostly due to having recently studied it during my uni degree (which has taken 14yrs so far).

Anyway, I've now decided having gotten SOAP working this week that it's a really cool thing and something worthy of my first post on my new blog.

For those of you that don't know SOAP is a another way of getting a remote machine to do work for you. Now perhaps you are thinking that well hey, we do this all the time with web pages, why do I need some special protocol to do the same thing.

Well, one problem with say having a script on a website that you perhaps pass some data to and it does some work and spits out some results is one of data validation. Your script needs to make sure that the data passed is what is expected.

Whilst this isn't that hard, you certainly have to be careful about it.

SOAP on the other hand, if done properly, allows you to publish an specification of what data should be passed to you (like a function call) and it's up to the sender to make sure the data is formatted correctly.

At my work I have an intranet which most things happen through, yet for some specific tasks I have a handful of machines spattered around the place. The intranet system needs to communicate with these other systems to get them to do useful things.

Until now I didn't really have a nice structured way of doing this until I discovered SOAP.

I use PHP for my scripting language and thus calling a 'function' on a remote machine looks exactly like calling a local function on the intranet. It's that easy.

Check out http://www.php.net/soap for more details.

The hardest part of the process was getting the WSDL file correct. This is a file that describes the functions available on the remote machine. For people new to XML it can be a bit daunting but I find it easy to steal from someone else who already has it working. Google is a good example. They allow you to make searches via SOAP. With PHP this is very easy to do, simply pass in the WSDL file and call the search function.

Anyway, this is my first post and I don't really know what else to say, I'm not much of a journalist yet so I'm still finding my style.

I will post more techie stuff as time goes on.

Feel free to comment on this if you wish. I'd like to hear from you.

Welcome to Nurd Land

Firstly I should introduce myself. I won't tell you my name 'cos, well, I like it that way but I will tell you that I live in Sydney, Australia work for an large IT company and am a self confessed geek.

Secondly, I already have a me blog but I figured that the people that know me and read that blog don't really care about geek stuff and thus I have created this blog.

Thirdly, I believe geek should be celebrated not frowned upon. I enjoy geeking it up and knowing more useless detail than the next geek. Its a measure of mental capacity if you ask me.

Ok. So that's a bit about me and about why I'm here. Perhaps people will post on here if I offer something useful. I plan on talking about all the projects and stuff that I'm working on and problems and how I've solved them (assuming that I have managed to).

So there it is, let me know if I'm providing useful information and I'll try and tone it down.

Enjoy.