Niklas Gustavsson wrote: > On Sun, May 9, 2010 at 8:23 PM, Bernd Fondermann <[email protected]> > wrote: >> What I wanted to achieve with the initial implementation, is that >> namespaces get propagated automatically within the scope. That's also my >> notion of how XML default namespaces are scoped and what the patch is >> solving. > > This would go against every XML API I know of. For example, what would > be the namespace of an element if I use it outside of its original > parent? > > Also, the namespace URI of an element is just as important as its > local name, so, I would rather this be explicit when we create an > element, than having to backtrace in the code whatever namespace the > parent might have. > >> So my resultion would be: >> + propagating default namespaces to inner elements is implicit. (means: >> possible reverting revision 941337, which is an strange revision number >> anyway ;-) > > Again, I would be strongly against this. It would make the Vysper XML > API work completely different from all the XML APIs (Java or not) I've > ever used. And I believe that's true for many other developers. The > XML APIs that I'm familiar with that behaves like this are DOM (Java > and Javascript), XOM, JDOM, DOM4J, .Net XmlDocument and SAX (yes, I'm > somewhat of an XML geek :-).
ok, let's talk more on code, so I can be sure to understand correctly. I'm argueing alongside the last example in http://www.w3.org/TR/REC-xml-names/ , chapter 6.2 This example is especially appropriate, as it includes beer: <?xml version='1.0'?> <Beers> <!-- the default namespace inside tables is that of HTML --> <table xmlns='http://www.w3.org/1999/xhtml'> <th><td>Name</td><td>Origin</td><td>Description</td></th> <tr> <!-- no default namespace inside table cells --> <td><brandName xmlns="">Huntsman</brandName></td> <td><origin xmlns="">Bath, UK</origin></td> <td> <details xmlns=""><class>Bitter</class><hop>Fuggles</hop> <pro>Wonderful hop, light alcohol, good summer beer</pro> <con>Fragile; excessive variance pub to pub</con> </details> </td> </tr> </table> </Beers> Now, I'd like to have an API like this: builder.add("table", "http://www.w3.org/1999/xhtml"). add("th"). add("tf"). addText("Name") ... and *not* builder.add("table", "http://www.w3.org/1999/xhtml"). add("th", "http://www.w3.org/1999/xhtml"). add("tf", "http://www.w3.org/1999/xhtml"). addText("Name") ... while you'd like it the other way round, right? Reason for my position: This is straihtforward. You don't redefine java variables when a new scope opens. You'd just redefine them to shadow/override the outer scoped variable. The inner XML elements are not arbitrary. Within a table, you'd expect td, tr etc. to occur. No need to redefine the namespace. However, if non-table elements occur, the namespace gets reset explicitly. And I don't think you can get rid of looking up outer namespaces in any serious implementation. In the second example, where every add() has an explicit namespace declaration, one would * either repeatedly render the declared xmlns on every element, no tracking of outer ns needed * or, not repeat rendering the declared xmlns, (like *all* XML examples I've seen so far) which can only be achieved by keeping track of what the current namespace is. I don't think XML like this: <table xmlns='http://www.w3.org/1999/xhtml'> <th xmlns='http://www.w3.org/1999/xhtml'> <td xmlns='http://www.w3.org/1999/xhtml'>Name ... would be very compatible with XMPP clients. And would put much more bytes on the wire than neccessary. Am I missing something? Bernd
