- From: <keshlam@us.ibm.com>
- Date: Fri, 19 Nov 1999 09:24:37 -0500
- To: Andrew n marshall <amarshal@zig.usc.edu>
- cc: www-dom@w3c.org
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) if(e.hasChildren()) print "<"+e.getNodeName+" "+printAttributes(e)+">" else print "<"+e.getNodeName+" "+printAttributes(e)+" />" getEndTag(Element e) if(e.hasChildren() 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