Re: Methods Request

Serialization of a DOM to XML syntax is one of the topics under
consideration for DOM Level 3. I don't know if anyone has considered
whether that should be able to generate the start and end tags separately
as well as rendering a complete subtree; that's probably worth considering.

You _can_ "recreate an empty element" from the DOM; it just requires having
your XML-syntax generator check whether the node has children or not.
Pseudocode for your proposed functions:

     getStartTag(Element e)
               print "<"+e.getNodeName+" "+printAttributes(e)+">"
               print "<"+e.getNodeName+" "+printAttributes(e)+" />"

     getEndTag(Element e)
               print "</"+e.getNodeName+">"

What you can't do is distinguish between the two ways of writing an empty
element: <foo></foo> and <foo/>. According to the XML spec, these are
semantically identical, and the DOM doesn't maintain the distinction
between them.

Joe Kesselman  / IBM Research

Received on Friday, 19 November 1999 09:24:52 UTC