December 8th, 2004
It’s often convenient to divide long XML documents into multiple files. The classic example is a book, customarily divided in chapters. Each chapter may be further subdivided into sections. Traditionally this has implemented via external entity references. For example,
<?xml version="1.0"?>
<!DOCTYPE book SYSTEM "book.dtd"[
<!ENTITY chapter1 SYSTEM "malapropisms.xml">
<!ENTITY chapter2 SYSTEM "mispronunciations.xml">
<!ENTITY chapter3 SYSTEM "madeupwords.xml">
]>
<book>
<title>The Wit and Wisdom of George W. Bush</title>
&chapter1;
&chapter2;
&chapter3;
</book>
However, external entity references have a number of limitations. Among them:
The individual component files cannot be treated in isolation. They often aren’t themselves full, well-formed XML documents. They cannot have document type declarations.
-
The document must have a DTD, and the parser must read the DTD. Not all parsers do.
-
If any of the pieces are missing, then the entire document is malformed. There’s no option for error recovery.
-
Only entire files can be included. You can’t include just one paragraph from a document.
-
There’s no way to include unparsed text such as an example Java program or XML document in a technical book. Only well-formed XML can be included, and all such XML is parsed. (SGML actually had this ability, but it was one of the features XML removed in the process of simplification.)
XInclude is an emerging specification from the W3C that endeavors to create a mechanism for building large XML documents out of their component parts which does not have these limitations. XInclude can combine multiple documents and parts thereof independently of validation. Each piece can be a complete XML document, a part of an XML document, or a non-XML text document like a Java program or an e-mail message.
Read the rest of this entry »
Posted in XML | 7 Comments »
December 2nd, 2004
Lots of people have been writing in to me with features they’d like to see here at the Cafes, especially with regard to the comment system. Some of these were already on my TODO list, but the site seemed to work and be useful now, so I didn’t want to wait to launch to implement absolutely everything. So herewith, in no particular order, is a peek at my TODO list:
Read the rest of this entry »
Posted in Web Development | 2 Comments »
December 2nd, 2004
When I was writing JavaBeans: Developing Component Software in Java, I lost over a day hunting for one bug. The program compiled and ran; but a label that was supposed to appear in the GUI wouldn’t show up, no matter what I did! The problem turned out to be in this line of code:
Font f = new Font("Serif", 12, Font.BOLD);
Can you see the bug? It’s certainly not obvious. In fact it’s so inobvious that I’ve made this mistake probably a dozen times since then, and it’s been a hard one to find every single time. I almost guarantee you can’t spot the bug without looking at the declaration for the Font constructor:
Read the rest of this entry »
Posted in Blogroll | 8 Comments »
December 2nd, 2004
In Java I/O, I wrote a Swing based GUI program that could display any file in a variety of encodings such as hex dump or ASCII. A screen shot is shown below. You can find the actual program source at Cafe au Lait or in Chapter 13 of Java I/O.

The biggest problem with this program is that after clicking the “View File” button, the user may have to wait for several seconds to several minutes before the file is displayed. Reading in a multi-megabyte file and converting it to a hex string is slow, even on a relatively fast machine with a fast hard drive. While the file is being read from the disk, the program is effectively frozen from the user’s perspective. This is not a good thing. Although there are undoubtedly still some optimizations that could be performed on the code to make it run faster, no matter how much it was optimized you could always throw a larger file at it that would make it seem frozen once again. Consequently I want to focus here not on optimizing the code, but on changing the user interface to make the program at least appear more responsive.
One general principle of user centered program design is to always give the user feedback, even if the feedback is no more significant than “Yes, I’m still running; No I haven’t frozen.” For simple operations an animated cursor like the Macintosh’s spinning beach ball may be sufficient . For longer operations, you should display a progress bar that indicates how much of the operation has been accomplished and how much remains to be done. Swing 1.1.1 lets you easily display progress bars in JOptionPanes like the one shown below:

Read the rest of this entry »
Posted in Blogroll | 2 Comments »
November 30th, 2004
The Cafes seems to be off and running. There were a few initial glitches that I have now cleaned up. Today’s project is to make the staging server work enough like the production server that I can use it for testing and debugging without affecting the production server. Yesterday I got stymied by a slight difference in how the PHP engines were configured. (The staging server didn’t have libtidy support that the site relies on heavily.)
At least three people tried to post with fictional or nospam e-mail addresses. Sorry. That won’t work. Anonymous posters are not supported. You must supply a valid e-mail address at least once to post, and it will be verified. It’s sad, but the biggest issue that has been raised most consistently by users is an unwillingness to provide an e-mail address due to fear of spam and worm droppings. While I hate spam as much as the next person, I am loathe to break a useful feature like mailto links just to avoid spambots. It’s the wrong solution to the problem. I am a big fan of spam filters including realtime black hole lists. If you’re not using them, you should be. If your ISP isn’t using them, you should find a new ISP. But in the meantime, I do wonder if there might be a middle ground that confuses spambots, Microsoft worms, and other venomous spiders without putting any noticeable roadbloacks in the path of legitimate users.
Read the rest of this entry »
Posted in Web Development | 5 Comments »