Friday 27 June 2008

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.

No comments: