You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Lucian Holland <le...@decisionsoft.co.uk> on 2006/08/14 00:47:09 UTC
Testing STAX event reader code with SAXXMLStreamReaderImpl
Hi,
I've started trying to test my event reader code with the initial
contribution for the SAXXMLStreamReaderImpl rather than Woodstox. I've
noticed a couple of minor bugs which I've corrected in my checkout to
try and get things working, but I'm now blocked on something more
substantial. The minor bits were:
- The code seems to assume that xmlns attributes will be in the
attributes passed into the startElement method; AFACIT this is only the
case if |http://xml.org/sax/features/namespace-prefixes is set to true
(false by default)[1] The result is that namespace bindings don't get
noticed properly unless this feature is set to true.
- getName() has the constructor arguments the wrong way round for QName;
also, it doesn't appear to pass in the prefix (this is also true for the
construction of attribute QNames in getAttributeName()), so you seem to
lose all prefix information!
- getPrefix() has a typo in the initial condition - both checks are for
START_ELEMENT, rather than one being for END_ELEMENT
The more complex problem I've come across is that initialElementAttrs()
sets the prefix of attributes to null if it finds no colon in the
attribute name; the problem with this is that getAttributeNamespace()
uses this prefix when looking up the namespace uri with a call to
getNamespaceURI on the NamespaceContextImpl, and this method throws an
IllegalArgumentException if null is passed in. I'm hesitant to wade in
and change stuff without consultation here given the recent discussion
on stax_builders about the use null in QNames... Seems like there should
be a consistent strategy on the ""/null thing to avoid this sort of
confusion... Thoughts?
Obviously happy to submit a patch for the simple stuff if appropriate
(and indeed the other bug when we decide how nulls should be used in
this case).
Thanks,
Lucian
[1] http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/Attributes.html
|
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Testing STAX event reader code with SAXXMLStreamReaderImpl
Posted by hua lei <hl...@gmail.com>.
Hi, Lucian,
Thanks for your reviewing my code.
On 8/14/06, Lucian Holland <le...@decisionsoft.co.uk> wrote:
> Hi,
>
> I've started trying to test my event reader code with the initial
> contribution for the SAXXMLStreamReaderImpl rather than Woodstox. I've
> noticed a couple of minor bugs which I've corrected in my checkout to
> try and get things working, but I'm now blocked on something more
> substantial. The minor bits were:
>
> - The code seems to assume that xmlns attributes will be in the
> attributes passed into the startElement method; AFACIT this is only the
> case if |http://xml.org/sax/features/namespace-prefixes is set to true
> (false by default)[1] The result is that namespace bindings don't get
> noticed properly unless this feature is set to true.
Thanks for your reminding. I will fix it.
> - getName() has the constructor arguments the wrong way round for QName;
> also, it doesn't appear to pass in the prefix (this is also true for the
> construction of attribute QNames in getAttributeName()), so you seem to
> lose all prefix information!
Yes, I will replace new QName(namespace, localpart) with new
QName(namespace, localpart, prefix)
> - getPrefix() has a typo in the initial condition - both checks are for
> START_ELEMENT, rather than one being for END_ELEMENT
>
Yes, surely it should check START_ELEMENT and END_ELEMENT.
> The more complex problem I've come across is that initialElementAttrs()
> sets the prefix of attributes to null if it finds no colon in the
> attribute name; the problem with this is that getAttributeNamespace()
> uses this prefix when looking up the namespace uri with a call to
> getNamespaceURI on the NamespaceContextImpl, and this method throws an
> IllegalArgumentException if null is passed in. I'm hesitant to wade in
> and change stuff without consultation here given the recent discussion
> on stax_builders about the use null in QNames... Seems like there should
> be a consistent strategy on the ""/null thing to avoid this sort of
> confusion... Thoughts?
The default prefix of attribute should be "" but not null.
> Obviously happy to submit a patch for the simple stuff if appropriate
> (and indeed the other bug when we decide how nulls should be used in
> this case).
>
> Thanks,
>
> Lucian
>
>
> [1] http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/Attributes.html
> |
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org
Re: Testing STAX event reader code with SAXXMLStreamReaderImpl
Posted by Michael Glavassevich <mr...@ca.ibm.com>.
Hi Lucian,
I believe Hua Lei is still working on the implementation (there's still
about a week before Google Summer of Code ends) though I'm not sure
whether he's aware of these issues. I just committed fixes for getName()
and getPrefix(). Can you open JIRAs for the other two problems?
In my opinion we should be storing the element and attribute namespace
URIs from the SAX events and returning them instead of looking them up
from the namespace context. This isn't just for performance reasons. It's
possible that an attribute reported by the SAX parser may have a namespace
but no prefix (for instance if it was defaulted from an XML schema). In
such a case the namespace context look-up won't even work.
Thanks.
Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: mrglavas@ca.ibm.com
E-mail: mrglavas@apache.org
Lucian Holland <le...@decisionsoft.co.uk> wrote on 08/13/2006 06:47:09 PM:
> Hi,
>
> I've started trying to test my event reader code with the initial
> contribution for the SAXXMLStreamReaderImpl rather than Woodstox. I've
> noticed a couple of minor bugs which I've corrected in my checkout to
> try and get things working, but I'm now blocked on something more
> substantial. The minor bits were:
>
> - The code seems to assume that xmlns attributes will be in the
> attributes passed into the startElement method; AFACIT this is only the
> case if |http://xml.org/sax/features/namespace-prefixes is set to true
> (false by default)[1] The result is that namespace bindings don't get
> noticed properly unless this feature is set to true.
>
> - getName() has the constructor arguments the wrong way round for QName;
> also, it doesn't appear to pass in the prefix (this is also true for the
> construction of attribute QNames in getAttributeName()), so you seem to
> lose all prefix information!
>
> - getPrefix() has a typo in the initial condition - both checks are for
> START_ELEMENT, rather than one being for END_ELEMENT
>
>
> The more complex problem I've come across is that initialElementAttrs()
> sets the prefix of attributes to null if it finds no colon in the
> attribute name; the problem with this is that getAttributeNamespace()
> uses this prefix when looking up the namespace uri with a call to
> getNamespaceURI on the NamespaceContextImpl, and this method throws an
> IllegalArgumentException if null is passed in. I'm hesitant to wade in
> and change stuff without consultation here given the recent discussion
> on stax_builders about the use null in QNames... Seems like there should
> be a consistent strategy on the ""/null thing to avoid this sort of
> confusion... Thoughts?
>
> Obviously happy to submit a patch for the simple stuff if appropriate
> (and indeed the other bug when we decide how nulls should be used in
> this case).
>
> Thanks,
>
> Lucian
>
>
> [1] http://java.sun.com/j2se/1.5.0/docs/api/org/xml/sax/Attributes.html
> |
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
> For additional commands, e-mail: j-dev-help@xerces.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: j-dev-unsubscribe@xerces.apache.org
For additional commands, e-mail: j-dev-help@xerces.apache.org