Categories
Music

Best of 2005

The upside of having a music subscription service is its all you can eat ability. Nevermind the upsides and downsides of the model, you get to listen to almost everything that is out there. In any case, this the music I found I liked the most during 2005.

Guero / Beck
This is such an original, fresh and interesting album. It aims in so many directions, from hip hop to folk and just manages to score on everything. If you did not have a chance to listen to other Beck albums (such as the more mellow ‘Sea Change’), what are you waiting for. Time to worship.

Future Leaders of the World / Lvl Iv
This is the other extreme of everything I wrote about Beck. This album is a masterpiece of derivative work. Nirvana reincarnate for poor people. Still, a very solid album that puts together angst with mostly well executed grunge. Now if the lyrics and the band bios were less irritating. Fun nonetheless.

Interpol / Antics
I got to know Interpol this year, so I include their awesome previous album, “Turn on the bright lights” in making them one of my favorite albums of the year. This Joy Division-inspired band manages to sound like a happier, albeit still dim-lit, version of the original. They sound too vain and appear to enjoy life too much than to do anything as bad as hurt themselves as the original band’s leader did. Their sound is clean, simple and brilliant with dramatic vocals. I like them.

Nine Inch Nails / With Teeth
I forgot this album the first time I posted this entry and I am doing it justice now. When you first listen to this album you think Trent Reznor lost it, but when you give it a second, third, fourth, chance, you get it. ‘With Teeth’ has some great songs, and some not so great songs. Albums like ‘Broken’ happen once in a lifetime probably (unless you are Beck), but Reznor with one armed tied behind his back is better than most of the crap out there.

Music I started listening to in 2005
The Greenhornes
Another blues-inspired band from Ohio (a la the Black Keys), but with a stronger Animals and Beatles influence. If you like Hammond organs and mid-60s rock, the Greenhornes are your band.

Lou Donaldson
With my growing fondness of Jazz comes my first favorite artist, Lou Donaldosn. A great saxophone player with decades of recordings under his belt, I find his albums from the early ’60s especially entertaining. A combination of funky lounge music and be-bop jazz, Lou takes me away when notihing else can.

Share
Categories
General

Validating an XML document against a schem

To validate the XML files I am generating against a schema, I used this very simplistic code:

DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(false);

factory.setNamespaceAware(true);

SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);

Schema schema = schemaFactory.newSchema(new File("my-schema.xsd"));

factory.setSchema(schema);

Document doc = factory.newDocumentBuilder().parse(new File("my-file.xml"));

If anything is invalid, exceptions are thrown.

Be sure to include the following line:

factory.setNamespaceAware(true);

otherwise you will get this cryptic error:
cvc-complex-type.3.2.2: Attribute 'xsi:noNamespaceSchemaLocation' is not allowed to appear in element ...

Share
Categories
Java

Java 1.5 bug – Transfromer needs some coaxing

My current class assignment requires me to produce XML. Not so wisely I am using DOM to build the Document, but then the benefit comes in the form of Java’s Transformer object. What a fine object it is – the one and only meant to commit your XML to a file.
Still, what used to work in Java 1.4 somehow broke in Java 1.5; Transformer no longer obeys the following instructions that are meant to set it to indent its XML output:

TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT,"yes");

Naturally, I Googled this issue and as usual, the best place to find an answer were the Sun Java Forums. Many people offered help but the one that actually cracked this problem was one xuemingshen in this thread: His solution — use an OutputStreamWriter object as the parameter for the StreamResult that will be used by the Transfomer when it performs the transformation. The code:


try
{
Source source = new DOMSource(myDOMDocument);
File outputFile = new File(fileName + ".xml");
FileOutputStream outputStream = new FileOutputStream(outputFile);
Result result = new StreamResult(new OutputStreamWriter(outputStream));

TransformerFactory factory = TransformerFactory.newInstance();
factory.setAttribute("indent-number", 4);

Transformer transformer = factory.newTransformer();

transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.INDENT,"yes");

transformer.transform(source, result);
}

catch… TransformerConfigurationException, TransformerException, FileNotFoundException

I am using a FileOutputStream object to output to file but an OutputStream object will do.
Thank you xuemingshen !

Share
Share