OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help



   Re: [xml-dev] Greenspun's tenth law rears its head: was InnerXml is like

[ Lists Home | Date Index | Thread Index ]

Bill de hÓra <dehora@amadan.net> wrote:

|> From: Miles Sabin [mailto:miles@milessabin.com]
|> [regarding these examples:
| <http://lists.xml.org/archives/xml-dev/200209/msg00718.html>]
|> Can you, in all honesty, say that the latter is cleaner, more
|> consistent and less confusing than the former?
| I can :) There's only one programming language to deal with in the XOM
| example. The former has Java with XPath 'macros'.

Yes, as a tree-building "little language".  Miles has already said that
there's a bit of devil's advocacy in all this, but that shouldn't prevent
us from exploring the idea.

| And at the back of both is the XHTML, which is the domain language 
| we're interested in.

That part was irrelevant.  I regretably got tired of foo-bar-quuxing for
an example.

| Fwiw, I don't see *either* of these as that desirable to program in (but
| probably better than what I'm already using). 

Which is...? ;-)

| By the looks of things, the problem seems to be in Java itself, not 
| anyone's particular proposal.

Yes.  Java has no native support for proper lists (ie trees), or for
variable argument lists (the best you can do is to pass an array in, but
writing out the contents of the array isn't a comfortable exercise.)  All
the things you really need to describe XML trees - association lists and
variable length heterogenous content - you have to fake somehow. 
| You can shorten the verbose XOM version a bit, if you don't mind
| non-idiomatic Java:
|   Element head = new Element("head")
|    .add(new Element("title)
|      .add("Example 3"))
|    .add(new Element("link")

Not in XOM.  Method chaining is Bad Java, so they say.  Mutators have void
return signatures.  Elliotte is taking a "purist" approach deliberately -
you should have come to his talk. :-)

| (why type "appendChild", when I can just type "add"?). 

Some people like long names.  In these days where IDE editors support name
completion, it isn't a big deal.  (I prefer short names myself, btw.)
| At this point, we might as well give in and use Lisp, being a natural
| fit for manipulating syntax trees. 

Well, the discussion seemed to heading that way.  Modulo the surface
syntax, isn't XPath very lispish in feel?

| As for InnerXML, it looks like Lisp's read-from-string function.

You wish!  The actual behavior has been described as a "bug", but I'm not
sure it isn't a dwim "feature" instead (tag omission).  We have seen the


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS