Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] toXML() instead of getStringForm()?

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: Kevin Herrboldt <kevin AT puppethead.com>
  • To: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] toXML() instead of getStringForm()?
  • Date: Wed, 25 Sep 2002 13:23:57 -0500

On Thursday, Sep 19, 2002, at 23:26 US/Central, Bradley S. Huffman wrote:

Elliotte Rusty Harold writes:

John Naylor suggested the following name change:

i just gave xom a quick look and like much of what i see. just one comment
for now, have you considered toXml() instead of getStringForm().
[...]
Is there some reason people don't like toString() for this functionality.

Having done quite a bit of XML stuff in my own code, I initially used toString() to return XML for an object. I quickly found, however, that this created a namespace collision since toString() is meant as a human-readable string. In particular, Swing classes like JList and JTree use toString() as default behavior when rendering objects. If you have a JList of XOM nodes (say) probably the last thing you want is the actual XML to be rendered.

toXML() is actually what I ended up going with for my own code, and I think it is a clear and natural choice for XOM. It describes exactly what you're getting. I also think getStringForm() is a good example of a "passive" function name (think active vs. passive voice writing) and isn't very clear to someone who is new to XOM, whereas toXML() is.





Archive powered by MHonArc 2.6.24.

Top of Page