John Blaze


I got John Blaze stuff, Y’all just ain’t reckognizin’!
(Quoted from the Mad Rapper on the Notorious B.I.G.’s 1st album.)

There were quite a few people looking for the original Johnny Blaze today. These people mistakenly ended up on my site. Hi, my name is Cliff and you’re here because I like hip-hop music. See, you thought you were following a link to some good information on the upcoming blockbuster Ghost Rider John Blazebut instead you landed here on some stoopid tech site listening to this dumb guy preach about blowing up the earth with programming technology you never heard of. So how does this happen? Well, there’s this thing called page rank that Google uses to classify the relevance of a page to your search term and it gets influenced by how many bars people like Method Man and Ghost Face spit which include miscellaneous references to comic book characters. (“What do you mean how many bars are spit?” Check it out, son.) In simpler words, you got here because I use words like “John Blaze” and talk about rappers that call themselves Ironman to sound cool while I explain computer stuff. Since Google doesn’t know the difference between Hip-hop and hip movies it sometimes hiccups and brings up sites that have nothing to do with what you were really looking for. Don’t navigate away just yet… (Aww dag! I probably lost most of you!) There’s still hope. I like Ghost Rider too. I-I can fill you in on why his head is inflamed the way it is. (or at least I could back when I was 12 and heavily into Marvel Comics.) Nah, maybe it is hopeless. Go back on Google and see what else fits. If you ever need to figure out how to work with an XSL stylesheet then come back. I got some tips.

Download some adware and help me make money


I was looking at my pitiful blog stats this morning (like I do every morning) and I noticed a referral from my site to a place I don’t remember linking to. I followed the link which lead me to one of those pyramid deal offering sites. You know the ones where if you referr just one person who referrs just two people, who some how referr five people that referr… whatever. I started thinking, “Hmm…I need more money because right now I can’t afford that starship I was looking to buy from the Chrysler Starship dealer.” It’s always seductive when somebody throws math at you as a quick and easy way to earn cash. However, I know better. When I was much younger I tried the whole pyramid through spam mail thing (before I understood what spam was and possibly before most people understood what spam was) and I checked my mailbox each day for the magical incoming cash.

Fool me once, shame… shame on you. Fool me twice, ya’… ya’ can’t fool me again.

(Quoted from the honorable G.W.)

As bad as I need to buy that starship (and I really do need something to fire my angle brackets of destruction) I’m not making an idiot out of myself anymore. Then I read the site some more because it still sounded enticing. According to the offer,

alls yuh haff tuh do is link to our site where we market this internet search bar. People will download the search bar and as they search you make money$$$!!! It’s so easy. Write a blog today and mention our service, that’s it! Completely free, no money invested! Contact us today and say, “Hey, gimme that searchbar money making servce.” You don’t even have to say “Hey”. Just say, “Gimme that searchbar money making servce.” Then you’ll be on your way!

No thanks. I think I would make out better if I just directly asked my readers for money. There’s an idea! Would you all give me some money? I really really need to buy my starship and time is runnning out. There’s only about 3047 more years until the apocolypse and I wanna cash in while Chrysler is still offering the sale. Just send a self addressed stamped envelope with an enclosed check or money order to the following address:

Cliff the future Emperor of America
3202 Apocolypse Lane
Mountkill, NY 19108

Have your check or money order made out to: “Cliff the future Emperor of America” and I’ll post each donation here on my site. You too can contribute to the eventual overrulling of the planet. It all starts here. Be among the first to have their names posted on my new “Hall of planetary Aim” page. Thank you in advance for your donations and understanding. Peace!

Thanks for visiting


Whassup yall? I just wanna thank everybody that has been visiting my site lately. My stats are still pretty weak compared to the more polished Bloggers like Joel, Kathy, and Rory but I like to think of it as my little corner of the net. I just looked at my stat log and I recently has 177 feed reader hits last Monday! That’s the biggest surge I’ve seen ever. It sounds puny compared to other places but for a fool like me it’s pretty impressive. I still dunno who most of you are, though a handful of you have taken time to introduce yourselves. I’m puzzled by the recent surge. It’s sky rocketed from 5 readers per day on average to 177 and now it’s fluctuating around 75. I hardly ever view the feed stats. Instead I look at my hit counter which normally reflects the amount of drunks and people trying to sell me male enhancement substances. [deleted inappropriate comment on enhancement products (it was a funny one too, you missed it!)] Feed stats are different though. They reflect dedication. It’s a total number of people willing to put up with my half ghetto hip-hop references confusing the heck out of my otherwise helpful technical content. Feed stats reflect the number of people willing to put forth effort required to add my site to their feed reader. If I have over a hundred dedicated readers then I must be saying something worth listening to. I’m not quite sure what that is. If you figure it out could you tell me so I can keep saying it? Or maybe it’s not cool to say the same thing over and over again. (Holler!) Maybe I should come up with some original material? I know one thing is certain. I gotta get back into discussing some of my more interesting technical topics. Isn’t that what my site is all about anyway? With that let me update all of my faithful readers on some statuses.

GSpec
I am behind on GSpec. I poked at it a little last week not making much progress. There is good reason behind my not keeping you all posted on it. If you knew the kinds of stuff I’ve been going through these past couple of weeks you would understand how impossible it is to keep up with something like that. In short my time has been completely overwhelmed with general stoopidity. The only thing I do keep up with is posting nonsense that you all will quickly get tired of reading. I do want to put GSpec out as open source but it needs just a little more polish before I can claim it as an alpha. Actually I can’t even claim it, somebody else wrote the code. So I’m want to rewrite it to be able to officially claim it as my own and plug it into JUnit as well. I’m thinking of a JUnit suite that will load and execute all of your GSpec files under JUnit. Right now GSpec has an overall shape similar to JUnit including initialization blocks and test blocks. Look for me to introduce the glue code shortly.

Secret Projects
The main reason I’ve been so unable to get anything done is because I keep taking on more work. I have these three other “simple” projects that I’ve been tinkering with for personal reasons. One of them is a thing for Career day at my daughter’s school. It’s about 25% finished and very rough but it’s a cool idea. Then there are two other projects that I can’t talk about. If I tell you I have to kill you and I wouldn’t want to get blood on my DKNY sweater so let’s just say it’s something necessary.

Work stuff
I created my own stylsheet language a while back and it works pretty good. It’s a simple XML grammar you can use for writing more complicated XSLT/FO stylsheets. I have unit tests and all that proove I know hwat I’m doing. The grammar was dveloped entirely using TDD while I put together a terrible looking UI that uses XStream in a half-assed way to serialize the GUI into the grammar. I slapped an abstract repository (that I still need help finishing) on the back end for users to be able to save their style templates and everything works horribly. The truth is I really don’t know what I’m doing once I get past the honeymoon stage of a particular project. The core is good but everything else suffers due to lack of focus. There’s a good idea in there somewhere waiting to be dug out.

Groovy Invaders
This embarrassment of a project reflects how terrible I am to both commiting to something and UI development. I’m able to move the ship and fire a rocket but that’s pretty much it. The aliens all have lead in their drawers and nothing else works. Theirs both a kink in the timing logic and a kink in my brain when it comes to opening the project. I can never get the right version of Groovy running in my development environment and things always seem to throw funny errors until I play with my project settings long enough to get it running like before. By that time its bedtime and I haven’t accomplished anything.

Groovy Maven2
After finding the secret to pandoras box (actually before that) I have managed to get Groovy code to compile under Maven2 without using trickery like Ant, GAnt, or the like. I’ve also figured out how to create M2 plugins using Groovy. All of this code was written by someone else and has been sitting on the Codehaus Mojo site for some time. I just downloaded and ran the stuff. There was also the missing Plexus compiler piece that I’m not sure I can remeber where I found it but hopefully someone will post a reminder.

XSLT Maven2
I’ve had a grwoing need or desire to treat my XSLT source as source code instead of resource files when using M2 to manage projects. For that reason I looked into copying the Groovy compiler Idea and creating an XSLTC plugin for M2. The idea started some time ago and stalled on my hard drive at work. I think I spun off on a tangent fixing some file system based logic I had no business touching. You know how you see one of those things (like the usage of a File path right in the middle of a unit test setup block) that you just can’t let go of? I modified some code from the Plexus compiler svn checkout and never could get things running the way they were before. I’ll look into it someday.

That’s most of the important stuff going on in my world. As you can see I’ve basically been doing nothing but getting stuck on FOP memory issues and more recently a X-platform SAX serialization issue. (Anybody know why sending System.getProperty(“line.separator”) to the ignorableWhitespace method on a content handler shows as an entity reference only on Windows?) While XML stabs me in the buttocks I get it from above with all the extra stuff I’ve been trying to do. Thanks again to all of my dedicated homies. If yall got other homies spread the word about my spot, it’s the best kept secret. Until later hit me up…

I can’t kopete with Windows


No that’s not a type-o in the title. I’m having an ongoing struggle with the more popular Windows Live messanger service. As some of you know, I stopped using Windows as my primary operating system a long time ago. Now when I check my mail, read my favorite blogs, or chat online with my work buddies I do it all from a Linux based desktop. That’s worked out just fine for most things but lately my Windows Live Account wants to integrate my hotmail. This leads to a constant nagging in Kopete, my instant messanger software of choice. Kopete keeps saying things like, “Check yo’ email fool!” It uses this rectangular boxy thing to nag me. The rectangular thing has these two buttons. Kopete-nag If I tell it to open my inbox then Konqueror fires up and gets me all excited. Konqueror leads me on, telling me things like “I’m logging into your Windows Live Messenger account. Relax, you don’t need XP!” Then the little progress bar fills and resets. Konqueror leads me on again, saying “Whoa, we gonna check some email today! It’s gonna be great!” Once more I watch progress bars fill and reset. Then here goes Konqueror again, “Isn’t it great with all of this KDE integration? Wait till you see what’s in your Hotmail inbox! I can actually connect to Windows services! Screw Redmond!” I sit through several minutes of excitement before it finally sinks in. Konqueror is playing head games with me. It never intended to show me any email! It was getting me all gassed up so I could sit there and look dumb. Ain’t that a terrible game to play on a person? Has your software ever played you like that? I mean, I could get to my email in a bunch of other ways which I don’t mind. But don’t lie to me and promise me email when all you’re showing me is empty progress bars! What do you think? Should I dump my software for deceiving me? Or is it my fault for being dumb enough to sit through several dialogs of empty progress? Hit me up people…

A green bar for 16 bars


The latest entry in the “Do my work for me sucka!” series invloves my FOP memory flop. I need a declarative XSLT algortihm that can split an element using sub-elements or sub-sub elements for the split. In simpler words (why do I always start with the most complicated explanation?) I need to do things like break a single <foo/> element with about 160 <bar/> elements into 10 <foo/> elements each holding 16 <bar/>s. (If you’re an average techie that doesn’t know why 16 <bar/>s is relevant, click the link above. If you’re one of my homies who can’t figure out why bar comes after foo click this link. If you’re here because you’re drunk again then click this link.) It sounds simple until you remember, “Hey, I’m a Java programmer! Where are my variables at?” Or maybe it sounds simple and it is simple because you said, “Hey, I’ve been coding XSLT for years! That’s nothing!” (You don’t even have to say “Hey”. Just say, “send me that Veralex brochure”.) If that’s the case then complete your answer in the box below. Your solution will then be graded and your final score emailed to you within the hour. You’ll also be automatically entered in a drawing to win this car. Mercedes SLR

My problem has always been switching back and forth between imperative style Java programming and the more functional style of XSLT. Your problem is that you worried about my problems which creates problems when you’re working on an answer to this problem.

So how does it work out? We can write a template to match the <foo/> element. (In my case I’ve went overboard and wrote a template to match a parameterized element.) Then we can count the bars that we have underneath. Because we have no real variable assignments in our non-imperative language of preference we have to do a little math-magic and group the stuff we’re interested in. We group and select the first entry in each group to operate on. If you’re still thinking imperatively you’ll pull out your favorite trusty <xsl:for-each/> construct and go to town. Because I’m smarter than you I’m going to smack your fingers and tell you to put that looping nonsense away. (Bad programmer! Didn’t your mother teach you some declarative manners?) Anytime you think <xsl:for-each/> you should think <xsl:apply-templates/> and <xsl:template/> instead. When you get to be as good as I am you’ll write code like this: <xsl:apply-templates mode="split" select="$element-to-split/child::*[position() mod 16 = 1]"/> Then you whip up a template that matches anything with a mode named split and you’ll get down to business.

What’s your business in the split template?
In our split-mode template we spit our 16 bars. (Any of you got experience in dropping it like it’s hot? I do but I’m a little rusty.) Here’s what I get for my split mode.

    <xsl:template match="*" mode="split">
        <xsl:param name="parent"/>
        <xsl:element name="{name($parent)}">
            <xsl:copy-of select="$parent/@*"/>
            <xsl:copy-of select=". | following-sibling::*[position() < 16]"/>
        </xsl:element>
    </xsl:template>

Once again I get fancy with passing the parent as a parameter and all. So now we have a quick and dirty split template that takes the first bar element in each group and spits it with 15 additional bars. (Straight lyrical prowess son! Don’t nobody spit bars like I do!) What’s wrong with that? In my project I need to split an FO page-sequence that includes headers/footers and other nested stuff. I need the split to start from the nested <flow/> element. (Check the flow cousin! The rhyme flow!) I need all the stuff over the flow to come along in each split element. Then it gets better. I have to dig in the flow (after I grab the mic) and break out rows nested in tables. Here’s the real deal. I need this test to pass:

    public void testComplicatedSplit() throws Exception
    {
        String xml = "<doc>\n" +
                "\t<parent atttr1=\"some val\" attr2=\"newval\">\n" +
                "\t\t<table name=\"a\">\n" +
                "\t\t\t<row val=\"1\"/>\n" +
                "\t\t</table>\n" +
                "\t\t<table name=\"b\">\n" +
                "\t\t\t<row val=\"2\"/>\n" +
                "\t\t\t<row val=\"3\"/>\n" +
                "\t\t\t<row val=\"4\"/>\n" +
                "\t\t</table>\n" +
                "\t\t<table name=\"c\">\n" +
                "\t\t\t<row val=\"5\"/>\n" +
                "\t\t\t<row val=\"6\"/>\n" +
                "\t\t\t<row val=\"7\"/>\n" +
                "\t\t\t<row val=\"8\"/>\n" +
                "\t\t</table>\n" +
                "\t</parent>\n" +
                "</doc>";

        String expectedXml = "<doc>\n" +
                "\t<parent atttr1=\"some val\" attr2=\"newval\">\n" +
                "\t\t<table name=\"a\">\n" +
                "\t\t\t<row val=\"1\"/>\n" +
                "\t\t</table>\n" +
                "\t\t<table name=\"b\">\n" +
                "\t\t\t<row val=\"2\"/>\n" +
                "\t\t</table>\n" +
                "\t</parent>\n" +
                "\t<parent atttr1=\"some val\" attr2=\"newval\">\n" +
                "\t\t<table name=\"b\">\n" +
                "\t\t\t<row val=\"3\"/>\n" +
                "\t\t\t<row val=\"4\"/>\n" +
                "\t\t</table>\n" +
                "\t</parent>\n" +
                "\t<parent atttr1=\"some val\" attr2=\"newval\">\n" +
                "\t\t<table name=\"c\">\n" +
                "\t\t\t<row val=\"5\"/>\n" +
                "\t\t\t<row val=\"6\"/>\n" +
                "\t\t</table>\n" +
                "\t</parent>\n" +
                "\t<parent atttr1=\"some val\" attr2=\"newval\">\n" +
                "\t\t<table name=\"c\">\n" +
                "\t\t\t<row val=\"7\"/>\n" +
                "\t\t\t<row val=\"8\"/>\n" +
                "\t\t</table>\n" +
                "\t</parent>\n" +
                "</doc>";
        testStyleSheet(xml, splitterStylesheet, expectedXml);
    }

The test stylesheet method is selfexplanatory in that it takes the inputXml runs it with the stylesheet and asserts the result matches the output XML. I could include the implementation but then I’d be showing you too much. Oh ok, here’s a rough example of what it would look like:

    private void testStyleSheet(Document inputDocument, URL styleSheet, String expectedXML) throws Exception
    {
        String returnedXML = doTransform(styleSheet, inputDocument);
        assertIsValidDocument("Transform produced an invalid document.", returnedXML);
        assertXMLEquals(expectedXML, returnedXML);
    }


Now the doTransform() method is self explanatory and the assertIsValidDocument() can be commented out. I secretly went from string input to a Document so you’ll need an overload method to do the same. If you copy all of the above Java into a class that extends XMLTestCase (from the nice folks at XMLUnit) then your editor will help you stub out the missing method intentional style. (You do have an editor that supports intentional programming don’t you? Get one here. Intentional programming is a loaded term. What I’m referring to is described here.) Give it a shot, finish my work for me and I’ll be your best friend. (That might not go far with you but at least you’ll get bragging rights.) I gotta go and try to come up with the solution first so you don’t steal my right to gloat about how much smarter I am than you. Hit me up people…

You know me from where?


Seomthing weird happened first thing this morning. I ran into someone in our office who ran into me online. It happened as I was walking in. I said hi to my boss cracking an occasional joke (as I always do when I see him in the morning) and I noticed there was a lady in the lunch room preparing bagels. My boss introduced me and she mentioned something about browsing the web and seeing one of my responses to an XML question. I’ve posted a lot of stuff on various forums helping others where I can help myself so I’m not sure which web site or which question she was referring to. It was a strange feeling because when she saw me she looked like she reckognized my face. I don’t have too many pictures of me on the net outside of my book review on Javalobby and what’s on top of this blog. Our introduction was brief and it left an erie feeling in me partly because I’ve never had anybody reckognize me from anywhere before and partly because I never think anybody is ever interested in anything I have to say. The internet is a powerful tool for broadcasting yourself and I think it’s sinking in how much impact a little bit of typing and mouse clicking can make. If you habitually post things on the net (either on your own site, or on any given site) be careful what you let loose. I try to make a habit of exercising caution when I post here but I’m sure there are things I’ve said that may have been better kept quiet. Remember once it’s posted it’s out there forever. Spooky right? Hit me up…

FOP memory goes Flop


Have any of you used F.O.P. before? I gotta tell you, it’s a fantastic tool for handling XSL-FO. The only problem is… umm… I forget… err… oh yeah, memory. I’ve been struggling far too long with the pigginess of F.O.P.’s memory requirements and now it’s starting to get to me. (Everything is starting to get to me lately because it’s just been one of those kinda months!) I’ve done all sorts of dancing around in XSLT to please the memory requirements of FOP and it’s just not worth while. When you produce FO grammar that nests a whole bunch of page data in one page-sequence element all of your heap memory packs its bags and proudly exclaims, “See ya! I’m off to FOP land!” So what I had to do was become the Sesame Street Count and figure out how many angle-bracketed things expand to text-like stuff to fit on each page.

The count“One, two, uh three! Ha…ha…haaaa! [lightning strikes loudly] Three <fo/> blocks under our current flow elements!!! I’ll keep counting! Four! Five! Six!!! [more lightning] Ha…ha…haaaa!!!! …”

It’s lots of fun and my two year old loves me for it but boy does it take time! What I would like to know is if there are any other open source Java FO APIs available. (I realize that’s a little like asking if there are any other purple flamingos named Camille living on the northen side of the Atlantic Ocean but cut me some slack. I’m frustrated!) Are there any better ways to produce PDF output from XML that don’t require tearing apart my brittle and already heavily-tied-to-FO-and-TrAX logic? (I have about 35-40 individual classes, and 50+ XSLT stylesheets that are constantly expecting their first cousin FO-TrAX over for dinner. It’s a combined total of roughly 40-50 KLOCS (KLocs are thousands of lines of code) of micro-managed brittle application design authored in part by yours truly.) Do I have any other options? I’m only trying to fix a bug, which to my boss equates to a few hours worth of development. In all reality it’s a cosmetic thing that would appear to be a two minute fix to most people but the code is so fragile that of course there’s extra work involved. Why can’t I just generate FO without counting lines? Why can’t I drop in another engine and be done with the whole mess? (Incidentally, I tried the both FOP trunk and trial version of RenderX a little over a year ago and still suffered OutOfMemory errors with large page-sequences.) Is there an overall flaw in the entire FO spec? If so, does George Bush know about it? Somebody really ought to inform him. Holla if you know better…