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

Re: Methods Request

From: Philippe Le Hegaret <plh@w3.org>
Date: Fri, 19 Nov 1999 15:12:11 +0100
Message-ID: <38355ABB.D0EF1733@w3.org>
To: Andrew n marshall <amarshal@zig.usc.edu>
CC: www-dom@w3.org
Andrew n marshall wrote:
> 
> Here are two method I'm looking for, mostly for debug purposes:
> 
>    DOMString Element.getStartTag();
>    DOMString Element.getEndTag();
> 
> I know they can both be created with the existing DOM (that is what I'm
> currently using), at least it terms of the logical structure.  What you
> can't do is recreate an empty element from the DOM.

If an element is declared as EMPTY, it has no content and then, you can
write in two ways :
<foo/>
<foo></foo>

Both are valids and are equivalents. Your problem is a serialization and DTD
problem: you should have the DTD to know if your element is declared as EMPTY
and also have a way during the serialization to choose if you want to write
an empty tag or a start tag and an end tag with no content. Serialization and
DTD will be addressed in DOM Level 3.

> In the case that the original XML document's element (assuming it came
> from a standard XML document and was not dynamically generated),
> getStartTag() should return "<TagName ATTRs... />", and getEndTag() should
> return an empty string.

A start tag is not an empty tag. Your getStartTag method can't return <foo/>.

> Where I'm using this is in reporting errors encountered in the XML
> documents semantics to the user and I want to match the original notation
> as closely as possible.  Sun's DOM implementation includes the toString()
> method (also very useful), it includes all the child elements as well.

It's not possible, with the DOM, to produce an exact copy of an XML document
(character entities are not exposed, no difference between <foo/> and
<foo></foo>).
Methods like addText("<foo>sdfggs</foo>") or toString are on our list of ideas.

Regards,
Philippe.
Received on Friday, 19 November 1999 09:12:54 GMT

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