Archive: April 14, 2002
I just added a lot of stuff to my software page. You can now check out version .80 of the markup parser I use to mark up my weblog posts, as well as my XML-RPC implementation, version .95 (almost done). So check it out, feel free to use the code, and tell me if you have any suggestions.
My family just spent hours walking around Ramapo reservation. Check out some pictures... I was just there! 
This is another test of my markup parser. I'm fixing a broken regex. The text here is quoted from another weblog post where I had a problem (though it's been changed a little to test a few things).
Slashdot had a crappy poll asking who the "coolest movie robot" was. They listed a bunch of robots I never heard of, but - hello? - they left out the Terminator, Johnny Five, and R2D2.
This is a test to show my dad and my brother how cool XML-RPC is.
This is a test to see how well w.bloggar pings weblogs.com.
Um, it didn't seem to do it? I suppose maybe I have to hit "Post and Publish" instead of just "Post", but that's the hook I put into my code to ping Weblogs.com. Ah well. Maybe I'll try w.bloggar's pinging again later, because I'm not going to comment out that code now. I'm going to bed.
Via blogsnob.idya.net, check out their new software, DBX.
DBX is essentially a full fledged database system.
It is completely written in PHP, and works using XML files as its native format. The database can be queried using standard SQL queries. DBX is the smallest, platform independent DBMS and is extremely easy to migrate to. For small databases, it is a good substitute for mySQL, Oracle, etc. The added advantage is that it saves the data as neat, readable, XML files - allowing easy compatibility.
The world now uses Relational Databases as a standard. Hierarchical Databases are making a comeback because of the flexibility they provide. DBX acts as an interface.
I have mixed thoughts. On the one hand, I'm thinking "that's darn cool", and on the other "in PHP?", and on the other (yes, I have three hands), a combination of "is this really useful? how well does it scale? is it robust? What kind of SQL support does it have?"
Via lgf, the best description of France ever:
France just likes to yell at us. They know we'll be back when it gets ugly. France is the insecure girl who mistreats her big lug of a boyfriend in public but always comes back crying when there's trouble -- car won't start, Nazis attacking, etc.
The best description of functional programming ever, from Adam Vandenberg, mixed in with a rant about CGI programming.
Will some data into existence. Now operate on that data with a massively nested function call, and be sure to include some mutually recursive calls.
Somehow it's not as funny on its own... he was comparing different programming styles, so there was some build-up 
It's probably on his mind since he blogged Advanced Programming Language Design by Raphael Finkel. (Wow, this link floated around a lot... I love following links like this. From here to here (the author was actually Dave Winer's teacher!), to here to Adam). The entire text of the book is online, and it looks like a neat book.
This is one of the links I meant to blog when I wasn't blogging 
Now for me to blog everything I didn't get to blog while I wasn't blogging. 
While trying to get my XML-RPC client to work, the most difficult problem I had was transforming the output of xml_parse_into_struct() into something useful to me. I kept trying to do it by the seat of my pants, and it wasn't working. I got really close, but couldn't get it how I wanted.
Just to show you an example of what I wanted to do... say you had an XML document like so (using lists just for indentation):
- <?xml version="1.0" ?>
- <methodResponse>
- <fault>
- <value>
- <struct>
- <member>
- <name>faultCode</name>
- <value>
- </value>
- </member>
- <member>
- <name>faultString</name>
- <value>You bastards!</value>
- </member>
- </struct>
- </value>
- </fault>
- </methodResponse>
I'd want to be able to transform it seamlessly back and forth between this data structure (in PHP):
<?php $array["methodResponse"]["fault"]["value"]["struct"]["member"][0]["name"] = "faultCode"; $array["methodResponse"]["fault"]["value"]["struct"]["member"][0]["value"]["int"] = "1"; $array["methodResponse"]["fault"]["value"]["struct"]["member"][1]["name"] = "faultString"; $array["methodResponse"]["fault"]["value"]["struct"]["member"][1]["value"] = "You bastards!"; ?>
I actually lied down on the floor with a printout of the data structure that xml_parse_into_struct() gives you and wrote down, in low-level pseudocode, what had to happen at each node. Then I was able to transfer that to code. There was one case I had to account for that didn't come up in the data I was working with at the time, but that was easy to add.
Here's the code:
<?php function XML_struct_transform($values){ $root = array(); $current_parent = &$root;
for($n = 0; $n<count($values); $n++){ $value = $values[$n]; $level = $value["level"]; $type = $value["type"]; $tag = $value["tag"]; $val = $value["value"];
if($type == "open"){ if($level > 1 and isset($current_level_parent[$level-2][$tag])){ #if you've already seen one of these tags $current_parent = &$current_level_parent[$level-2]; if(!isset($current_parent[$tag][0])){ #if you've only seen *one* of these tags $temp = &$current_parent[$tag]; unset($current_parent[$tag]); $current_parent[$tag][0] = &$temp; $current_parent[$tag][1] = array(); $current_parent = &$current_parent[$tag][1]; }else{ #if you've seen more than one of these tags $count = count($current_parent[$tag]); $current_parent[$tag][$count] = array(); $current_parent = &$current_parent[$tag][$count]; } }else{ $current_parent[$tag] = array(); $current_parent = &$current_parent[$tag]; } $current_level_parent[$level-1] = &$current_parent;
}elseif($type == "complete"){ if($level > 1){ $current_level_parent[$level-2][$tag] = $val; }else{ $root = array($tag => $val); } } } return $root; } ?>
This is a new post made with w.bloggar over XML-RPC. Awesome.
And I was even able to edit it. ROAR!!!
Oops, little error in my API made a duplicate Should be fixed.
Ok, it updated correctly, but my site returned an error to the program. My XML is probably wrong. This is just to check.
There we go. I was missing an array() around my return value.
Also, I just want to note that my blog isn't 'fully compliant' with the Blogger API. It doesn't support things like getTemplate and setTemplate which make no sense for my blog.
This is a new post made with w.bloggar over XML-RPC. Awesome.
My XML-RPC client is done! Wahoo!.
I'm using this amazing program I never knew existed, w.bloggar. It's way better than BlogBuddy (which kept crashing on me). I think I have something like one more method in the Blogger API to implement before I can post and edit without having to go to my website at all.
This post is here for me (besides celebrating) to edit with w.bloggar once I finish the Blogger API. Roar!
I just did a little victory dance out in the hallway. Oh, and Ethereal was very helpful (I use my markup parser too liberally) in diagnosing problems that came up. It allowed me to watch the entire conversation between w.bloggar and my website so I could see immediately if anything was wrong. Very useful.
|
Generated in about 0.071s. (Used 7 db queries) |
The Elegant Universe
Well I have finally found the crazyguy that preaches useless nonsencein A...
Joseph Baxter: Jan 7, 11:07pm