Henri Sivonen has written an excellent list of do’s don’t’s for producing XML: HOWTO Avoid Being Called a Bozo When Producing XML. Many of these are old habits for me, but some I’m still trying to internalize some of the others.
Henri Sivonen has written an excellent list of do’s don’t’s for producing XML: HOWTO Avoid Being Called a Bozo When Producing XML. Many of these are old habits for me, but some I’m still trying to internalize some of the others.
Comments
do you get many of your links from del.icio.us?
The final advice in "Avoid adding pretty-printing white space in character data" seems pretty crazy to me. I guess it's legal XML but if the idea is to make the XML more readable it fails miserably. Better advice would have been to just don't do it and create a style sheet.
djQuickTip: No, I've never made del.icio.us part of my habitual routine. Why do you ask?
Pete: I agree with you. I've never seen XML formatted as he suggests. I've split an element across multiple lines, but the reason was to spread out its attributes so I could see them better, no so that the character content would be indented.
There are alot of people out there who advocate a very bloated, combersome, do everything, XML world view. If you take this persons advices you will have an unmanageable nightmare. I suggest that you validate your XML, but make sure it's readable, and keep it simple. Don't use an XML library, do print.
Sean: I have to disagree: if you use print to create XML, you'll spend the rest of the lifetime of the product chasing down quoting bugs. Use a simple XML streamer.
Well, yes, I do use, for example StringEscapeUtils.escapeXml from apache commons.
If you find yourself having to explicitly escape stuff all the time, maybe you're printing the wrong things:
http://arctrix.com/nas/talks/htmltext.pdf
Add a comment: