W3C home > Mailing lists > Public > www-dom@w3.org > October to December 1999

Re: Methods Request

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
Message-ID: <8525682E.004F2748.00@D51MTA03.pok.ibm.com>
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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 22 June 2012 06:13:47 GMT