Red Squirrel Reflections
Dave Hoover explores the psychology of software development

Dave Hoover

All [Atom]
Craftsmanship [Atom]
Dynamic [Atom]
Intersection [Atom]
Learning [Atom]
Links [Atom]
Polyglot [Atom]
Projects [Atom]
XP [Atom]
Old Blog

Obtivian Blogs

Andy Maleh
Colin Harris
Fred Polgardy
Jim Breen
Kevin Taylor
Todd Webb
Turner King
Tyler Jennings


March 2009 (1)
January 2009 (1)
December 2008 (1)
October 2008 (3)
September 2008 (1)
June 2008 (4)
April 2008 (3)
March 2008 (1)
February 2008 (1)
August 2007 (1)
July 2007 (1)
June 2007 (1)
May 2007 (4)
April 2007 (3)
March 2007 (5)
February 2007 (6)
January 2007 (6)
December 2006 (10)
November 2006 (5)
October 2006 (8)
September 2006 (8)
August 2006 (5)
July 2006 (12)
June 2006 (7)
May 2006 (5)
April 2006 (5)
March 2006 (4)
February 2006 (2)
January 2006 (5)
December 2005 (5)
November 2005 (3)
October 2005 (3)
September 2005 (6)
August 2005 (4)
July 2005 (7)
June 2005 (14)
May 2005 (6)
April 2005 (8)
March 2005 (9)
February 2005 (11)
January 2005 (16)
Old Archives


Sat, 15 Jan 2005

Quote Manager Project -- Day 2

An ongoing pet project blog...

So now I know how to read XML data and, using Java 5.0, transform it into HTML. I also have an XSL style sheet that duplicates the look and feel of my current quotes page. Again I find myself wondering what to do next. Again I will put on my customer hat and consider what I want. Let's look at the original plan:

  • I want to change the quotes page to be sorted by quoter. There should be a list of all the quoters at the top. Their names should link down to their quotes on the page below.
  • I want to use a simple Swing application to manage the quotes.
  • The Swing app will store the quotes in XML. The app will have the ability to transform this XML into HTML via XSLT.
I could add sorting to my style sheet. Or I could do another spike that reads in XML data and writes updates. Updating XML sounds more intersting, but as a customer, I'd like to see the sorting I've asked for. So let's sort...

OK, sorting in XSL is easy. I just had to add two lines beneath my <xsl:for-each>...

		<xsl:for-each select="quotes/quote">
			<xsl:sort select="quoter"/>
			<xsl:sort select="author"/>
But that doesn't do what I want. First of all, it sorts by first name. Secondly, it puts all of the quoter-less quotes first, and then adds the quote by Weinberg last. As my fellow ThoughtWorker Dave Wood would say: "Boooo."

Actually, this is good. It looks like I'm going to need to change my XML data structure in order to allow for the sorting I need. I'm glad I chose to do this task before the XML update spike, since the data format would have changed. Pulling into the station...

OK, I've changed the XML data format to break quoter and author names down into first and last names like:

		<quoter url="">
But that still doesn't solve the problem of wanting to sort by quoter, since most quotes just have authors. As the customer, I'm OK with sorting by authors for now, so I'll change the sorting tags to:
		<xsl:for-each select="quotes/quote">
			<xsl:sort select="author/last"/>
			<xsl:sort select="author/first"/>
I'm checking in.

My next task is to spike reading and updating the XML file from Java. I wonder if I could use some of my XSL transformation code? It looks like the first half of my previous spike could come in handy...

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder = factory.newDocumentBuilder();
        Document document = builder.parse("sample.xml");
But I'm not familiar with how to use a Document. Back to the Java XML tutorial...

[/projects/quotes] permanent link

powered by blosxom