Completed ImtLinkSet class
This class handles a <linkGrp>
and its component <link>
elements. It's now functioning well and tested; it can read and write itself from a DOM element successfully, and provide a list of links with a particular target <zone>
, or target <text>
element. I'm gradually getting a handle on how best to do all these things.
The issue of XML namespaces remains. I had assumed that if I set all elements to the same namespace explicitly, and then output the document as a text string, I would see a sensible serialization whereby child elements with the same xmlns
as their parent would not have an explicit xmlns
attribute. Instead, I see the xmlns
attribute (I know it's not really an attribute, but there's no other practical word) on every single element.
So I'm now figuring that what I actually need to do is to make all my XML handling namespace-free, so that the root namespace for the document is set once, and all the elements that don't need an explicit namespace don't get one. That doesn't mean they have an empty one -- that just results in an empty xmlns
attribute. They need to be created with createElement()
rather than createElementNS()
.
Namespace prefixes can be handled with createElement("myNs:myElement")
and setAttribute("myNs:myAtt" "myVal")
, which is what I think I'll do with (for instance) @xml:id
. So I'll have to refactor my <linkGrp>
and <link>
code to remove the namespace handling. Annoying, but things will be simpler. The issue of how to handle possible embedded SVG or other namespaces is still not clear to me.