Re: Namespace support in SAX serialisers
by Dominic Mitchell other posts by this author
Oct 16 2005 2:05AM messages near this date
view in the new Beta List Site
Re: Namespace support in SAX serialisers
|
Re: Namespace support in SAX serialisers
& XSLT On Sat, Oct 15, 2005 at 10:53:39PM +0200, A. Pagaltzis wrote:
> * Dominic Mitchell <dom@[...].net> [2005-10-15 21:45]:
> > A. Pagaltzis wrote:
> > >Well, as I said, it ignores Name completely.
> >
> > What do you think it should do? I reckon:
> >
> > * Look at LocalName first and then fall back to Name if it's
> > not present (ignoring the prefix on Name).
> >
> > * Look at Prefix first and if not present, divine it from Name.
>
> Well, that???s why I asked if there is any specification about
> this. It would be nice if we could avoid having every module
> author have to decide how his module should infer missing bits
> from other missing bits.
Certainly. I'll wait for more input from the local luminaries before
implementing.
> > I'll have to say that I'm still figuring out what's going on in
> > there. It's certainly given me new respect for the complexity
> > of namespaces. :-)
>
> That???s why it should be solved once in the serialiser instead of
> over and over in the applications??? :-)
>
> It isn???t really *that* difficult (though I don???t know how complex
> things are in Genx), but it???s certainly real easy to screw it up.
The namespace processing is (according to the comments :-) the most
complicated part of Genx. I think it may go further than the XML spec
itself requires, although that's possibly because it's attempting to
create Canonical XML. For example, I hadn't even considered declaring
the same namespace twice with different prefixes on the same element,
yet Genx contains code to forbid this. Which I think is probably a good
thing.
> > Could you give me the sequence of events that you're sending so
> > that I can see what's going on? Thanks.
>
> At the beginning of processing,
>
**SNIP**
>
> and it???s when I emit the `div`???s start_element event that
> ::SAXWriter crashes and burns.
Excellent. This is definitely a bug in SAXWriter. It should be able to
cope with this. I'll add that as a test case and get a fix done ASAP.
I would add however, that Genx dislikes having multiple declarations for
the same prefix in the same document. With only one declaration, it can
go straight to it, otherwise it has to search through its stack of
declarations on every single call to start or end an attribute/element.
So you may be better off adding in an "xhtml" prefix instead of trying
to reuse the default namespace. For more discussion, see:
http://www.tbray.org/ongoing/genx/docs/Guide.html#speed
(I should probably add bits of that to the POD for XML::Genx)
> Incidentally I wonder if it the SAX spec (or Perl-SAX spec)
> requires those start_prefix_mapping events of if it wouldn???t be
> the explicit `Prefix` given for the start_element event shouldn???t
> be enough to cause the serialiser to emit the requisite xmlns
> attribute, given that the prefix is currently mapped to a
> different namespace than the one given.
Good point. Again, I'll have to defer to those who know better than I.
Although I wonder if the Java SAX bindings have anything to say on the
matter...
http://www.saxproject.org/namespaces.html
Interestingly, they don't pass in the Prefix to the Element events at
all.
-Dom
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Thread:
A. Pagaltzis
Petr Cimprich
A. Pagaltzis
Petr Cimprich
A. Pagaltzis
Robin Berjon
Petr Cimprich
Dominic Mitchell
A. Pagaltzis
Robin Berjon
Dominic Mitchell
Robin Berjon
A. Pagaltzis
Robin Berjon
A. Pagaltzis
Robin Berjon
A. Pagaltzis
A. Pagaltzis
Dominic Mitchell
Robin Berjon
Dominic Mitchell
A. Pagaltzis
Dominic Mitchell
Dominic Mitchell
|