You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xindice-dev@xml.apache.org by James Bates <ja...@amplexor.com> on 2002/10/22 14:36:19 UTC

[VOTE] SAX I/O inconsistency

As it currently stands, the Xindice source tree has a problem with SAX and 
namespaces. A decision is needed to fix it. Summary at bottom.

Full explanation:
=============
When sending a document using SAX (i.e. doing a setContentAsSAX() on an 
XMLResource, and then using the returned ContentHandler), you must use 
startPrefixMapping() to signal namespace bindings, and you should not include 
the namespace bindings as attributes in startElement. This is quite normal 
and sane behaviour in itself.

The trouble is that when requesting a document using getContentAsSAX() 
(supplying your own ContentHandler), your startPrefixMapping() methods are 
called correctly, but startElement is called with attributes that also 
include namespace bindings (i.e. "xmlns:xxx" attributes). Thus the SAX that 
Xindice itself returns is unsuitable for upload into itself! This is quite 
inconsistent behaviour IMHO.

To fix it, I delved into the code and found this:
*) Xindice internally stores the namespace bindings as *attributes*. The code 
that generates SAX from a Xindice resource 
(org.apache.xindice.xml.sax.SAXEventGenerator) clearly shows this. 

*) It is possible to either fix SAXEventGenerator such that it no longer sends 
these (IMHO incorrect) namespace-binding "attributes". This way, inputting 
SAX remains "fussy" (as it should be), but the output generated by 
getContentAsSAX() is usable as input.

*) The alternative is to make Xindice accept namespace bindings both in 
startPrefixMapping() and in "attributes" in startElement. The code that needs 
chaning in this case is not actually in Xindice, but in the xmldb-sdk.jar 
auxiliary JAR (which comes from Infozone). (in the 
org.xmldb.api.sdk.modules.setContentHandler class)

The xmldb-sdk.jar currently in Xindice's lib directory is dated 6 december 
2001, but the sources, available from infozone's CVS were actually updated in 
January 2002 and allow this more flexible SAX input. The JAR should thus be 
replaces in Xindice's CVS.

VOTE summary:
=============

Do we want:

1) To patch XMLResource's getContentAsSAX() to no longer include namespaces 
among attributes. (might break brain-damaged software that relies on such 
"attributes"!!)

2) To update the xmldb-sdk.jar in Xindice so that setContentAsSAX() on 
XMLResource's accept namespace declarations in both startPrefixMapping() and 
among the attributes sent in startPrefix.


My personal vote goes to option 1.

James

Re: [VOTE] SAX I/O inconsistency

Posted by Murray Altheim <m....@open.ac.uk>.
Kevin Ross wrote:

> VOTE summary:
> =============
> 
> Do we want:
> 
> 1) To patch XMLResource's getContentAsSAX() to no longer include
> namespaces 
> among attributes. (might break brain-damaged software that relies on
> such 
> "attributes"!!)
> 
> +1 I've had several issues in particular with namespaces and xml schemas
> and I've had to work around it so far.


I'm going to bow out of voting, but I thought I'd say that we might
perform a small survey of other apache software to be sure that what
is being called "brain dead" might not be more common than thought.

Maybe "brain dead" would be a better description of the whole XML
namespace design in the first place. Duh. This kind of thing should
be done in the prolog, not the document instance. If this had been
adhered to in the first place a lot of troubles would have been
avoided. A *lot*.

Murray

......................................................................
Murray Altheim                  <http://kmi.open.ac.uk/people/murray/>
Knowledge Media Institute
The Open University, Milton Keynes, Bucks, MK7 6AA, UK

            If you're the first person in a new territory,
            you're likely to get shot at.
                                                     -- ma


Re: [VOTE] SAX I/O inconsistency

Posted by Tom Bradford <br...@dbxmlgroup.com>.
Correction:
http://xml.org/sax/features/namespaces is for namespace reporting in 
general
http://xml.org/sax/features/namespace-prefixes is for namespace prefix 
reporting

On Tuesday, October 22, 2002, at 09:35 AM, Tom Bradford wrote:

> On Tuesday, October 22, 2002, at 08:00 AM, Kevin Ross wrote:
>> 1) To patch XMLResource's getContentAsSAX() to no longer include
>> namespaces
>> among attributes. (might break brain-damaged software that relies on
>> such
>> "attributes"!!)
>>
>> +1 I've had several issues in particular with namespaces and xml 
>> schemas
>> and I've had to work around it so far.
>
> Woah woah woah...  Reporting namespaces using startPrefixMapping() is 
> a SAX feature, so it can either be turned on or off, it's not an 
> immutable behavior.  Any changes that take place are going to have to 
> take into consideration the appropriate feature (I believe it's 
> http://xml.org/sax/features/namespaces).
>
> There are plenty of applications that process XML as an intermediary, 
> and would prefer to just pass namespace declarations through as 
> attributes rather than deal with them on the infoset level.
>
> IMO, the current namespace system has to be the worst late addition to 
> XML.  Of course, the worst early addition was DTDs, but I digress.
>
> --
> Tom Bradford - http://www.tbradford.org/
> CTO - The dbXML Group - http://www.dbxml.com/
> Apache Xindice - http://xml.apache.org/xindice
>
>
>
--
Tom Bradford - http://www.tbradford.org/
CTO - The dbXML Group - http://www.dbxml.com/
Apache Xindice - http://xml.apache.org/xindice


Re: [VOTE] SAX I/O inconsistency

Posted by Tom Bradford <br...@dbxmlgroup.com>.
On Tuesday, October 22, 2002, at 08:00 AM, Kevin Ross wrote:
> 1) To patch XMLResource's getContentAsSAX() to no longer include
> namespaces
> among attributes. (might break brain-damaged software that relies on
> such
> "attributes"!!)
>
> +1 I've had several issues in particular with namespaces and xml 
> schemas
> and I've had to work around it so far.

Woah woah woah...  Reporting namespaces using startPrefixMapping() is a 
SAX feature, so it can either be turned on or off, it's not an 
immutable behavior.  Any changes that take place are going to have to 
take into consideration the appropriate feature (I believe it's 
http://xml.org/sax/features/namespaces).

There are plenty of applications that process XML as an intermediary, 
and would prefer to just pass namespace declarations through as 
attributes rather than deal with them on the infoset level.

IMO, the current namespace system has to be the worst late addition to 
XML.  Of course, the worst early addition was DTDs, but I digress.

--
Tom Bradford - http://www.tbradford.org/
CTO - The dbXML Group - http://www.dbxml.com/
Apache Xindice - http://xml.apache.org/xindice


RE: [VOTE] SAX I/O inconsistency

Posted by Kevin Ross <Ke...@iVerticalLeap.com>.
VOTE summary:
=============

Do we want:

1) To patch XMLResource's getContentAsSAX() to no longer include
namespaces 
among attributes. (might break brain-damaged software that relies on
such 
"attributes"!!)

+1 I've had several issues in particular with namespaces and xml schemas
and I've had to work around it so far.

-Kevin