This is the Soapbox Crypt. Fresh content can be found at Patrick's Soapbox.

text/xml-newstyle

Wow. Today I discovered a piece on the Apple site about PHP, and on that page about parsing XML (there for the sake of demonstration reading an iTunes library xml file. My 4.1mb library file took a while to load...)

So with that in hand I decided it was time to rewrite the XML parser that powers pftqg.com. After starting that, I decided to rewrite the format, and thus text/xml-newstyle was born, which leaves the <metadata> section intact, changes the <sidebar> slightly, but has completely rewritten the <contents< section.

I wrote the initial version of the parser as a stand alone script, basically running through parsing the metadata section and sidebar section. Then I wrote the section that parsed the contents section, rather roughly, but hell it produced a workable result (see nxml, shows the XML source, PHP source, and a live view). So I went about working in to the current system.

I had two 'base' classes: pftqgbase, and pftqgbasenoxml (noxml extending the former), pftqgbase did a whole lot of XPath stuff for me, and supported the pftqgpageplain (the current xml format) and pftqgpagephotogallery (the photo-galleries). When it came to working with NXML, I quickly realised that pftqgbasenoxml would actually work as a better starting point. So pftqgbasenxml was born, extending noxml.

The nxml xml file proved to be quite a useful test case (and showed up a bug in the _parseP function, changing all the $kThisNode's to $kChildNode's was done by hand, and I should've find/replaced all, but still).

343 lines of code later, the class is in existence, and it works quite nicely. The demo page is now up (view it's source), as is the source of pftqgbase_nxml class.

I also concluded that adding k to the beginning of a variable name makes it look cooler, or at least it seemed to. It was also an easy way to know if something was a throwaway variable (if it had a k at the beginning then it wasn't) or not.

Hmm, long, and geeky. Sorry non techies.

About this entry

You’re currently reading “text/xml-newstyle,” an entry on Patrick’s Soapbox.

Published: October 21, 2003 12:10 PM.

Filed in My Site .

self.DoubleShot()

more at ma.gnolia.
Feedsubscribe to the doubleshot feed.

Recently on Flickr