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 Elliotte Rusty Harold <el...@metalab.unc.edu> on 2002/05/29 18:32:06 UTC
SAX survey: expected local name for non-namespace qualified
elements
Hello,
Recently I raised some issues about inconsistencies in the SAX
documentation with regard to how local names are reported to the
startElement() method:
public void startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String qName,
Attributes atts)
throws SAXException
Specifically the question is, when namespace processing is turned on
as it is by default (i.e. when http://xml.org/sax/features/namespaces
is true), is it acceptable for a parser to report the local name of a
non-namespace qualified element as the empty string? For example,
consider this document with no namespaces:
<document>
<para>
Hello!
</para>
<document>
When a parser calls startElement() or endElement() for these
elements, is it allowed to report their local names as the empty
string, and only provide the name as the qName argument? Or must it
report the local names as "document" and "para"?
David Brownell, the current maintainer of SAX, surprised me by
claiming that it is OK to report the local names as the empty string
for non-qualified elements even when the namespaces feature is true.
He says that such elements do not have local names.
I've checked with 4 existing parsers (Xerces-2, Piccolo, Crimson in
JDK 1.4, and Oracle 9.0.2.0.2) and they all report the actual name as
the local name argument. The SAX documentation is contradictory on
this point. The infoset clearly states that non-namespace qualified
elements do have local names, but the infoset is not normative for
SAX.
Here is the question:
1. Before now, what was your understanding of this point? When
writing and teaching did you tell your students to rely on local
names or qNames for non-namespace qualified elements? What have you
relied on in your code?
2. If you've implemented a parser, what does your parser do?
3. If you participated in the original specification of SAX2 back in
1999/2000 what were you thinking about this then?
Note that the question is *not* what SAX should do now. The question
is what was people's understanding of this point so that going
forward we can be clearer about what is and is not conformant, and so
that we can all write interoperable code. I'm trying to understand as
much as possible what the original intent of SAX2 was, and I'm hoping
that we don't discover that 50% of people understood it one way and
50% understood it the opposite way, though that's certainly possible.
I've cc'd this to various people who have been involved in SAX in one
way or another, as well as posting it to the sax-devel, xerces-j-dev,
and xml-dev mailing lists. Discussion should probably take place on
sax-devel <http://lists.sourceforge.net/lists/listinfo/sax-devel>,
but it will where it will. Thanks for your input.
If you'd like to read the original exchange that led to this question
see http://www.geocrawler.com/lists/3/SourceForge/13179/0/ and start
with the first post on "misleading sentence on project page"
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Consensus? expected local name for non-namespace qualified elements
Posted by Karl Waclawek <ka...@waclawek.net>.
> on what happens when namespace processing is turned *on*. In
> particular, I am prepared to offer the following tentative consensus:
>
> When the feature http://xml.org/sax/features/namespaces has the value
> true (as it does by default), SAX 2.0 parsers *must* report a
> non-empty local name for all elements and attributes, whether
> namespace qualified or not. A parser that reports the local name as
> the empty string when http://xml.org/sax/features/namespaces is true
> is simply not compliant with the SAX 2.0 specification.
>
> Does anyone want to stick their hand up and disagree with this statement?
OK, I agree.
It's not enough, though.
Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Consensus? expected local name for non-namespace qualified
elements
Posted by Elliotte Rusty Harold <el...@metalab.unc.edu>.
I've just returned from Kentucky and read through the messages of the
last few days. There's clearly a significant amount of disagreement
on what does and what should happen when namespace processing is
turned *off*. However, there seems to be nearly unanimous agreement
on what happens when namespace processing is turned *on*. In
particular, I am prepared to offer the following tentative consensus:
When the feature http://xml.org/sax/features/namespaces has the value
true (as it does by default), SAX 2.0 parsers *must* report a
non-empty local name for all elements and attributes, whether
namespace qualified or not. A parser that reports the local name as
the empty string when http://xml.org/sax/features/namespaces is true
is simply not compliant with the SAX 2.0 specification.
Does anyone want to stick their hand up and disagree with this statement?
--
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo@metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
| The XML Bible, 2nd Edition (Hungry Minds, 2001) |
| http://www.cafeconleche.org/books/bible2/ |
| http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/ |
+----------------------------------+---------------------------------+
| Read Cafe au Lait for Java News: http://www.cafeaulait.org/ |
| Read Cafe con Leche for XML News: http://www.cafeconleche.org/ |
+----------------------------------+---------------------------------+
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Robin Berjon <ro...@knowscape.com>.
On Friday 31 May 2002 18:14, David Brownell wrote:
> > What is the localName in "foo:bar" and "foo:bar:foo" which are legal
> > element names in XML 1.0 and should therefore be passed through when
> > namespaces are off?
>
> I'd expect that localName would still be defined to be the syntactic
> "strip off the only prefix" transform of qName that it is in other
> cases ... so "foo:bar" would become "bar", and "foo:bar:foo" would
> be an error (normally reported as an empty localName).
I don't think that makes much sense... If namespaces are off, then there is
no such thing as a prefix to be stripped off. And raising an error for the
latter would be a strange decision knowing that it's a legal name when
namespaces are off.
--
Robin Berjon <ro...@knowscape.com> -- for hire: http://robin.berjon.com/
Avoid clichés like the plague.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace
qualified elements
Posted by David Brownell <da...@pacbell.net>.
>> And
>> moreover, I'd certainly _prefer_ that elements not in any namespace
>> still have a localName (regardless of the namespace setting)
>
>
> What is the localName in "foo:bar" and "foo:bar:foo" which are legal
> element names in XML 1.0 and should therefore be passed through when
> namespaces are off?
I'd expect that localName would still be defined to be the syntactic
"strip off the only prefix" transform of qName that it is in other
cases ... so "foo:bar" would become "bar", and "foo:bar:foo" would
be an error (normally reported as an empty localName).
- dave
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for
non-namespace qualified elements
Posted by "Simon St.Laurent" <si...@simonstl.com>.
On Fri, 2002-05-31 at 15:18, Arnaud Le Hors wrote:
> I guess you could argue this makes sense. But it's not what I would
> expect and others argue that the localName should be the same as the
> qName in this case. Others may argue for something else yet.
>
> What this proves to me is that people don't agree. And there is no way
> to say who's right who's wrong because there is no definition to refer
> to. The fact is that the notions of local name, prefix, and qualified
> name are only defined in the context of Namespaces. Once you're out of
> this context they therefore don't mean anything.
>
> This is why I think it is best to leave them alone (i.e., having them be
> null) when namespaces processing is off.
I think you've missed the point that the SAX2 API itself IS
namespace-aware, and that flipping a switch to turn off
namespace-processing doesn't necessarily mean turning off chunks of the
API.
I have an incredibly hard time believing that SAX filter writers such as
myself should have to write their code to check different arguments in
the API depending on whether a particular flag was set a given way.
I have an even more difficult time finding any benefit whatsoever in
reporting information that is actually available as null, though I
suppose I can write yet another SAX filter which compensates for such
peculiar practice.
If you genuinely don't want to think about namespaces and don't want to
know, SAX1 is always an option.
--
Simon St.Laurent
Ring around the content, a pocket full of brackets
Errors, errors, all fall down!
http://simonstl.com
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for
non-namespace qualified elements
Posted by "Simon St.Laurent" <si...@simonstl.com>.
At 10:53 AM 6/2/2002 -0400, Karl Waclawek wrote:
>Simon St.Laurent wrote:
>
> > If "namespace processing is off and we've never heard of namespaces", then
> > we've never heard of QNames either. If you insist on going this route,
> > you'd better change the API to remove the notion of QName when namespace
> > processing is off. "Local name" might at least mean "the name local to
> the
> > element" in cases without any understanding of namespaces.
>
>I understand it the same way. The confusion in this thread really is:
>if NS processing is off, then which should really represent the
>element name - qName or localName? I agree with you that localName is
>the more natural candidate.
I'm also not certain that we want to encourage developers to look to qName
for anything other than prefix-retrieval in any event. I keep hearing of
developers who rely solely on qName whatever the status of
namespace-processing, and I guess it works for now...
Simon St.Laurent
"Every day in every way I'm getting better and better." - Emile Coue
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Rob Lugt <ro...@elcel.com>.
Simon St.Laurent wrote
>
> In the interest of application portability, I'd recommend requiring
> reporting the name of the element as localName when namespace processing
is
> turned off.
>
FWIW, I Agree. I think of the local name as being the name of the element,
minus the namespace prefix (if any). When namespace processing is disabled,
there is no prefix - so localName should be equal to the literal name of the
element.
~Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [xml-dev] RE: [Sax-devel] Re: SAX survey: expected local name for
non-namespace qualified elements
Posted by Ronald Bourret <rp...@rpbourret.com>.
"Simon St.Laurent" wrote:
>
> At 12:42 PM 6/2/2002 -0700, Yuval Oren wrote:
> ><my:doc/>
> >
> >With namespace processing off, SAX2 compliant parsers can provide a
> >localName value of either "" or "doc", while qName must be "my:doc". If this
> >were changed in a SAX 2.1 release, 2.1-compliant parsers would always
> >provide a localName value of "my:doc". That would bring us back to square
> >one: you can't rely on localName when namespace processing is off.
>
> And my point is that the localName is "my:doc" and the QName is meaningless
> in this case.
Agreed.
-- Ron
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
RE: [Sax-devel] Re: SAX survey: expected local name for
non-namespace qualified elements
Posted by "Simon St.Laurent" <si...@simonstl.com>.
At 12:42 PM 6/2/2002 -0700, Yuval Oren wrote:
>Regardless of what's more natural, at this point doing anything other than
>sticking with the current specification would be pointless. Take this
>document:
>
><my:doc/>
>
>With namespace processing off, SAX2 compliant parsers can provide a
>localName value of either "" or "doc", while qName must be "my:doc". If this
>were changed in a SAX 2.1 release, 2.1-compliant parsers would always
>provide a localName value of "my:doc". That would bring us back to square
>one: you can't rely on localName when namespace processing is off.
And my point is that the localName is "my:doc" and the QName is meaningless
in this case.
It's nice to realize how inflexible a parameter-based API can be, I suppose.
Simon St.Laurent
"Every day in every way I'm getting better and better." - Emile Coue
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Karl Waclawek <ka...@waclawek.net>.
David Brownell wrote:
> Karl Waclawek wrote:
> >
> > I understand it the same way. The confusion in this thread really is:
> > if NS processing is off, then which should really represent the
> > element name - qName or localName? I agree with you that localName is
> > the more natural candidate.
>
> Actually that'd be a new confusion. The original question dealt with
> the namespacing-on-but-no-namespace case, where the SAX spec says both
> URI and localName must be provided (or neither) ... even though some
> implementations are providing a localName with empty URI.
Well, in that case the question is: What does it mean if "no URI is provided".
If you allow URIs to be empty strings, then you will always have an URI,
if you say that an empty URI string means that there is no URI,
(which seems correct to me) then localName must be empty too, but if
namespace-prefixes is false, qName is optional, and you have no place
"obligated" to report the name.
Even if you would have to use qName then, I find it still
not elegant that you have to switch between localName and qName
depending on whether the element name is in a namespace or not.
How much less confusing the Expat approach is:
You pass:
-URI
-Name
-Prefix
It's always clear what goes where.
>
> Arnaud's point (that localName is not defined except in the context
> of namespacing) is IMO good. Conformant code was _never_ allowed to
> rely on localName in such cases.
Well, qName is also not defined outside of namespacing.
What does "qualified" mean when NS processing is off?
I still say that localName sounds less bound to namespaces then qName.
What's the problem if we make localName and qName always available,
and they are the same if there is no namespace.
Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Rob Lugt <ro...@elcel.com>.
Yuval Oren wrote
> > >
> > > With namespace processing off, SAX2 compliant parsers can provide a
> > > localName value of either "" or "doc"
> >
> > This is nonsense. If namespace processing is off, what specification
are
> > you invoking to come up with a localName of "doc"?
> >
> > ~Rob
>
> By "namespace processing off" I meant that the
> "http://xml.org/sax/features/namespaces" feature was set to false. I was
> thus referring to the Javadoc for ContentHandler.startElement():
>
> * the Namespace URI and local name are required when the namespaces
> property is true (the default), and are optional when the namespaces
> property is false (if one is specified, both must be);
>
> I read this to mean that if a SAX2 parser so chooses, it can process the
> element for namespaces even though the feature is off. And that's how we
get
> a localName of "doc".
I see. I have always understood the http://xml.org/sax/features/namespaces
feature to mean "behave as a vanilla XML 1.0 processor without reference to
the Namespaces in XML recommendation".
I think there are good reasons for treating the option in this way, rather
than just using it as a flag to control the parameters to startElement().
For one thing, the Namespaces recommendation introduces "namespace
constraints", (e.g. no ':' in entity name), which I would expect to be
flagged [1] by an XML processor in namespace mode but ignored when in plain
XML 1.0 mode.
~Rob
[1] xmlvalid treats namespace constraint violations as fatal errors when
namespaces are enabled
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
RE: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Yuval Oren <yu...@bluecast.com>.
> > <my:doc/>
> >
> > With namespace processing off, SAX2 compliant parsers can provide a
> > localName value of either "" or "doc"
>
> This is nonsense. If namespace processing is off, what specification are
> you invoking to come up with a localName of "doc"?
>
> ~Rob
By "namespace processing off" I meant that the
"http://xml.org/sax/features/namespaces" feature was set to false. I was
thus referring to the Javadoc for ContentHandler.startElement():
* the Namespace URI and local name are required when the namespaces
property is true (the default), and are optional when the namespaces
property is false (if one is specified, both must be);
I read this to mean that if a SAX2 parser so chooses, it can process the
element for namespaces even though the feature is off. And that's how we get
a localName of "doc".
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Rob Lugt <ro...@elcel.com>.
Yuval Oren wrote
> Take this document:
>
> <my:doc/>
>
> With namespace processing off, SAX2 compliant parsers can provide a
> localName value of either "" or "doc"
This is nonsense. If namespace processing is off, what specification are
you invoking to come up with a localName of "doc"?
~Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
RE: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Yuval Oren <yu...@bluecast.com>.
> Karl Waclawek wrote:
> >
> > I understand it the same way. The confusion in this thread really is:
> > if NS processing is off, then which should really represent the
> > element name - qName or localName? I agree with you that localName is
> > the more natural candidate.
>
> Actually that'd be a new confusion. The original question dealt with
> the namespacing-on-but-no-namespace case, where the SAX spec says both
> URI and localName must be provided (or neither) ... even though some
> implementations are providing a localName with empty URI.
>
> Arnaud's point (that localName is not defined except in the context
> of namespacing) is IMO good. Conformant code was _never_ allowed to
> rely on localName in such cases.
>
> - Dave
Regardless of what's more natural, at this point doing anything other than
sticking with the current specification would be pointless. Take this
document:
<my:doc/>
With namespace processing off, SAX2 compliant parsers can provide a
localName value of either "" or "doc", while qName must be "my:doc". If this
were changed in a SAX 2.1 release, 2.1-compliant parsers would always
provide a localName value of "my:doc". That would bring us back to square
one: you can't rely on localName when namespace processing is off.
Yuval
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace
qualified elements
Posted by David Brownell <da...@pacbell.net>.
Karl Waclawek wrote:
>
> I understand it the same way. The confusion in this thread really is:
> if NS processing is off, then which should really represent the
> element name - qName or localName? I agree with you that localName is
> the more natural candidate.
Actually that'd be a new confusion. The original question dealt with
the namespacing-on-but-no-namespace case, where the SAX spec says both
URI and localName must be provided (or neither) ... even though some
implementations are providing a localName with empty URI.
Arnaud's point (that localName is not defined except in the context
of namespacing) is IMO good. Conformant code was _never_ allowed to
rely on localName in such cases.
- Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Karl Waclawek <ka...@waclawek.net>.
Simon St.Laurent wrote:
> If "namespace processing is off and we've never heard of namespaces", then
> we've never heard of QNames either. If you insist on going this route,
> you'd better change the API to remove the notion of QName when namespace
> processing is off. "Local name" might at least mean "the name local to the
> element" in cases without any understanding of namespaces.
I understand it the same way. The confusion in this thread really is:
if NS processing is off, then which should really represent the
element name - qName or localName? I agree with you that localName is
the more natural candidate.
> >Those are both categories of implementation variance that the current
> >SAX spec allows, though which (thankfully) not many implementors have
> >taken advantage of. In the interest of application portability, I'd
> >be glad to see them removed in a SAX 2.1 release.
>
> In the interest of application portability, I'd recommend requiring
> reporting the name of the element as localName when namespace processing is
> turned off.
In order to satisfy everybody, I would say, qName = localName when
NS processing is off.
Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for
non-namespace qualified elements
Posted by "Simon St.Laurent" <si...@simonstl.com>.
At 08:12 AM 6/1/2002 -0700, David Brownell wrote:
>Hmm, in that case it might also be worth just stipulating that the URI
>and localName must always be reported as empty strings when namespace
>processing is disabled ... as it stands today, processors are allowed
>to report them in that case (but not required). That is, if that
>processing is turned off ("out of that context"), it's really off.
I disagree completely. I write all of my filter code to rely on localName
and URI - with no ill-effects when there is no URI - see below for more on why.
>On the other hand, I don't think I've heard anything but agreement to
>the notion that qName should always be reported ... at least when
>processing "real XML" instead of something that already discarded
>the prefixes being used.
If "namespace processing is off and we've never heard of namespaces", then
we've never heard of QNames either. If you insist on going this route,
you'd better change the API to remove the notion of QName when namespace
processing is off. "Local name" might at least mean "the name local to the
element" in cases without any understanding of namespaces.
>Those are both categories of implementation variance that the current
>SAX spec allows, though which (thankfully) not many implementors have
>taken advantage of. In the interest of application portability, I'd
>be glad to see them removed in a SAX 2.1 release.
In the interest of application portability, I'd recommend requiring
reporting the name of the element as localName when namespace processing is
turned off.
Simon St.Laurent
"Every day in every way I'm getting better and better." - Emile Coue
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Karl Waclawek <ka...@waclawek.net>.
> What this proves to me is that people don't agree. And there is no way
> to say who's right who's wrong because there is no definition to refer
> to. The fact is that the notions of local name, prefix, and qualified
> name are only defined in the context of Namespaces. Once you're out of
> this context they therefore don't mean anything.
>
> This is why I think it is best to leave them alone (i.e., having them be
> null) when namespaces processing is off.
So, if all of them are null, how do I get the name?
Karl
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace
qualified elements
Posted by David Brownell <da...@pacbell.net>.
> What this proves to me is that people don't agree. And there is no way
> to say who's right who's wrong because there is no definition to refer
> to. The fact is that the notions of local name, prefix, and qualified
> name are only defined in the context of Namespaces. Once you're out of
> this context they therefore don't mean anything.
>
> This is why I think it is best to leave them alone (i.e., having them be
> null) when namespaces processing is off.
Hmm, in that case it might also be worth just stipulating that the URI
and localName must always be reported as empty strings when namespace
processing is disabled ... as it stands today, processors are allowed
to report them in that case (but not required). That is, if that
processing is turned off ("out of that context"), it's really off.
On the other hand, I don't think I've heard anything but agreement to
the notion that qName should always be reported ... at least when
processing "real XML" instead of something that already discarded
the prefixes being used.
Those are both categories of implementation variance that the current
SAX spec allows, though which (thankfully) not many implementors have
taken advantage of. In the interest of application portability, I'd
be glad to see them removed in a SAX 2.1 release.
- Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: [Sax-devel] Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Arnaud Le Hors <le...@us.ibm.com>.
David Brownell wrote:
>>>And
>>>moreover, I'd certainly _prefer_ that elements not in any namespace
>>>still have a localName (regardless of the namespace setting)
>>>
>>
>>What is the localName in "foo:bar" and "foo:bar:foo" which are legal
>>element names in XML 1.0 and should therefore be passed through when
>>namespaces are off?
>>
>
> I'd expect that localName would still be defined to be the syntactic
> "strip off the only prefix" transform of qName that it is in other
> cases ... so "foo:bar" would become "bar", and "foo:bar:foo" would
> be an error (normally reported as an empty localName).
I guess you could argue this makes sense. But it's not what I would
expect and others argue that the localName should be the same as the
qName in this case. Others may argue for something else yet.
What this proves to me is that people don't agree. And there is no way
to say who's right who's wrong because there is no definition to refer
to. The fact is that the notions of local name, prefix, and qualified
name are only defined in the context of Namespaces. Once you're out of
this context they therefore don't mean anything.
This is why I think it is best to leave them alone (i.e., having them be
null) when namespaces processing is off.
--
Arnaud Le Hors - IBM, XML Standards Strategy Group / W3C AC Rep.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: SAX survey: expected local name for non-namespace qualified elements
Posted by Arnaud Le Hors <le...@us.ibm.com>.
David Brownell wrote:
>
> And
> moreover, I'd certainly _prefer_ that elements not in any namespace
> still have a localName (regardless of the namespace setting)
What is the localName in "foo:bar" and "foo:bar:foo" which are legal
element names in XML 1.0 and should therefore be passed through when
namespaces are off?
--
Arnaud Le Hors - IBM, XML Standards Strategy Group / W3C AC Rep.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
Re: SAX survey: expected local name for non-namespace qualified
elements
Posted by David Brownell <da...@pacbell.net>.
> public void startElement(java.lang.String uri,
> java.lang.String localName,
> java.lang.String qName,
> Attributes atts)
> throws SAXException
Note that the API specification (javadoc) has always said that the
URI and localName go together: "if one is specified, both must be".
> Specifically the question is, when namespace processing is turned on as
> it is by default (i.e. when http://xml.org/sax/features/namespaces is
> true), is it acceptable for a parser to report the local name of a
> non-namespace qualified element as the empty string?
My reading of the API spec says that if the uri is the empty string,
the localName must also be empty.
However I certainly agree that's not what most parser do today (though
I've certainly seen parsers that implement the letter of the spec).
And that, in part because of those implementations, that's what folk
are likely to expect -- regardless of what the API spec says. And
moreover, I'd certainly _prefer_ that elements not in any namespace
still have a localName (regardless of the namespace setting)
I think that SAX 2.1 should explicitly change, to stipulate that
localName is never empty (regardless of the setting of namespace
flags) except possibly in error cases like undeclared prefixes.
In fact I'd like that guarantee for qName too... :)
- Dave
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org