Microsoft %$#!(*
I use the Microsoft NET framework for programming. An epub book is all XML and NET has extensive classes for dealing with XML. Of course, as always with MS, you have to always be on the lookout for gotcha’s. Case in point.
<books xmlns=”Whoopdeedoo.html” />
That is a node, or element, in XML, books is the name and Whoopdeedoo.html is the namespace.
The specification states that all child nodes inherit the namespace of their nearest parent in the hierarchy if they have no namespace declaration of their own.
NET has several methods for creating these elements. The two I’ve used most often are:
XmlElement elem = new XmlElement(string name), and,
XmlElement elem = new XmlElement(string name, string namespace).
One would think that the first would create an element like <book /> and the second would create an element like books above. Not so!
XmlElement book = new XmlElement(“book”); results in <book xmlns=”” />, which if book is a child of books above, will break the inheritance chain, because it says that book has no namespace. In order to get <book /> you have to use XmlElement book = new XmlElement(“book”, “Whoopdeedoo.html”). The internals will look up the inheritance chain, see that that namespace is defined in an ancestor, and give you <book />. It’s an axiom in programming that the more typing, the more errors. Forcing people to retype that namespace in each and every child node will inevitably lead to errors, many of them not caught.
This little bit of nonsense is why you can count me firmly among the Microsoft haters.