Gmail helps with email subtleties

Let’s say you send out an email to several people, and a recipient does a Reply-All to say something, but adds yet another recipient at the same time. Would you notice? Would you want to notice, so you don’t accidentally say something you shouldn’t?

Gmail highlights these new recipients in bold. Presumably it inspects the previous emails in the “conversation” it’s a part of, and notices that some new people have joined the discussion. An innovative idea that solves a problem that I never even realized as a problem.

Now, if only they could do something about the accidental Reply-All…

Building up to a home theatre

  1. Watching DVDs on the right monitor while tinkering on the left detracts from the quality of both activities.
  2. Seems pointless to buy a TV of a size that will give a reduced experience from what I’m used to.
  3. CRT TVs at 30″+ are very heavy, and I don’t have a car or much space.
  4. A TV box using non-CRT technologies (LCD, plasma, rear projection) is very expensive.
  5. A front projector costs less per inch of screen than non-CRTs at 30″+.
  6. Found a projector that comes with a built-in DVD player, built-in speakers, and rave reviews.
  7. The visuals are good, but the speakers lack punch.
  8. Surprise one-day online sale on speakers. Entry-level prosumer speakers are heavily discounted. The “quantity remaining” slowly counts down, and ten minutes left before an appointment.
  9. Speakers are more high-end than I’ve ever had. Each speaker needs its own input signal, so I need a receiver.
  10. Receiver’s nice, but how do I put the speakers at the right height? Need to get some stands.
  11. Speakers placement is okay, but the speaker wire it came with isn’t long enough. Time to buy some overpriced speaker cable.
  12. Oh right, I need to send the audio from the projector’s DVD player to the receiver. Go back for an overpriced optical cable.
  13. Four hours to measure distances, cut and strip cable, read the user manuals, and concoct protection for the high-priced cables from a certain feline terrorist.

Yay! It sounds great, it looks great, everything is pretty much secure and tucked away neatly. I’m very happy with the final result.

Although… a well-stuffed leather couch would make movie and video game marathons more comfortable…

XML transform bug in Java 1.5’s JAXP implementation

I’m a little bit disappointed. I try to always assume that I’m in the wrong, and the libraries, carefully selected with an eye to maturity, are in the right. Without trust in one’s foundations, development goes much slower.

In Java 1.5 (1.5.0_06), Sun integrated the JAXP api and an implementation of it (Xalan). I’ve already stumbled on a performance problem in that implementation. This new problem is less serious in real impact, but it’s more of a “real” bug in that it’s not a sliding scale like performance.

There’s very little difference between this program:

 public class DomViaDomTransform {      public static void main(String[] args) throws Exception {         File source = new File(args[0]);         File stylesheet = new File(args[1]);          StreamResult out;          DOMSource src = new DOMSource(              DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(               new FileInputStream(source)));         DOMSource style = new DOMSource(              DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(               new FileInputStream(stylesheet)));          out = new StreamResult(System.out);          TransformerFactory factory = TransformerFactory.newInstance();         Transformer xf = factory.newTransformer(style);          xf.transform(src, out);      } } 

and this program:

 public class StreamViaStreamTransform {      public static void main(String[] args) throws Exception {         File source = new File(args[0]);         File stylesheet = new File(args[1]);          StreamResult out;          StreamSource src = new StreamSource(new FileInputStream(source));         StreamSource style = new StreamSource(new FileInputStream(stylesheet));          out = new StreamResult(System.out);          TransformerFactory factory = TransformerFactory.newInstance();         Transformer xf = factory.newTransformer(style);          xf.transform(src, out);      } } 

However, if you run them with the default JAXP implementation in 1.5, the first program will not transform the input XML. You’ll still get output, but the output will be the stylesheet.

For instance, take this stylesheet:

 <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  <!-- Default copy everything. --> <xsl:template match="node()|@*">   <xsl:copy>     <xsl:apply-templates select="node()|@*"/>   </xsl:copy> </xsl:template>  </xsl:stylesheet> 

which is a direct copy transformation. If we feed in the following as the input XML:

 <?xml version="1.0" encoding="UTF-8"?> <foo/> 

the second program (the one using StreamSource instances), will generate the same XML as output. With the first program (the one using DOMSource instances), you get the stylesheet as the output XML.

Silly bug, minor impact, easily worked around, but definitely broken. However, this is enough to convince me switch to Saxon, a drop-in JAXP replacement. The authour, Michael Kay, I understand to be very passionate and picky about all things XML, which is bad if you want to trade words I guess, but great for me as someone who wants a bug-free implementation of JAXP. I’m writing Java software in my spare time; I don’t have time to distrust my libraries.

Sun hasn’t recognized my bug submission yet, so it may be a duplicate of a known problem (none that I could find using the search engine, though), or I could be using the classes incorrectly. I don’t see how the latter is possible though, as putting Saxon on the classpath to become the new JAXP implementation corrects the problem, without recompilation.

  • Go to Random Post

  • Recent Posts

  • Recent Comments

    Ressie Nuncio on Getting Dell 1700 laser printe…
    GJ on Slow XPath evaluation for larg…
    Osvaldo on Slow XPath evaluation for larg…
    GJ on Slow XPath evaluation for larg…
    GJ on Slow XPath evaluation for larg…