Amy,
SAX should be calling all your handlers in the order that they appear in the XML, what folks do in thier handlers in their business. Why should the SAX calls come out of order? SAX does not pre-read them into a list then feed them to the application programmer. For writing, it may vary from one implementation to another, as I said. Regardless, this does not create a crisis for anybody. The "oid" can be ignored at any level as unwanted 'extra' data. Ignoring it is easy. Acting on it is a choice, at a very low level, a choice that opens up new possibilities. The reason it is first, is because the only way we can parse directly to the intended destination is if we can find it first. If we were to support this optimization with "oid" in the 2nd position, where would we put data until we knew where to put it - or implemented another way, should we parse all the attributes to discover that there is no "oid"? then we would have to back up and reparse if we found it, because now we have a destination. It's first because it's most streamlined that way, and that is after all the whole purpose of the whole idea. It was a good question and I hope that this explains it. Brian > Date: Mon, 24 Mar 2014 16:23:52 -0400 > From: amyzing@talsever.com > To: xmlboss@live.com > CC: xml-dev@lists.xml.org > Subject: Re: FW: [xml-dev] RFC for XML Object Parsing > > On Mon, 24 Mar 2014 14:03:02 -0600, Brian Aberle wrote: > > You said, > >> You do realize that this means "this is not XML"? > >> > >> You can't even guarantee attribute order in SAX. Suggesting that > >> attribute order matters is pretty baffling, altogether. > > > > While Reading via SAX the attribute order will be detectable. > > No. They. Won't. > > See: http://www.saxproject.org/apidoc/org/xml/sax/Attributes.html > > "The order of attributes in the list is unspecified, and will vary from > implementation to implementation." > > See also: > http://www.saxproject.org/apidoc/org/xml/sax/ContentHandler.html#startElement(java.lang.String,%20java.lang.String,%20java.lang.String,%20org.xml.sax.Attributes) > > > While > > Writing via SAX - I don't know, does that depend on parser > > implementation? Can anyone answer this? It could conceptually be XML > > 2.0(100% backward compatible), or it could conceptually be "a > > protocol", this is mostly a matter of view. > > I do not understand why you insist that it must be the first attribute, > anyway. Just treat it specially. The collection of attributes is > well-represented by an abstraction (in any programming language) that > represents a set or a map, though the possibility of namespaced > attributes complicates the construction of the key. > > For your specific purpose, I cannot see why you don't just define > ba:oid (where xmlns:ba="uri:something-that-you-own") and done. Then the > specialized faster processing can check whether there's a ba:oid > attribute on a particular element (or subtree) and treat it > appropriately. Nothing terribly exciting to see, there. > > No doubt I'm missing something. :-) > > Amy! > -- > Amelia A. Lewis amyzing {at} talsever.com > And now someone's on the telephone, desperate in his pain; > someone's on the bathroom floor, doing her cocaine; > someone's got his finger on the button in some room-- > no one can convince me we aren't gluttons for our doom. > -- Indigo Girls |