[xslt] Re: [xml] Text-Entities and Namespaces?



Daniel Veillard writes:
> On Fri, Jan 11, 2002 at 03:52:38PM +0100, Morus Walter wrote:
> > Hi,
> > 
> > though the following sample is connected to xslt, the problem itself
> > seems to be a libxml issue, so I write here:
> > 
> > I was trying to beautify some xslt output be adding linebreaks in the
> > stylesheet. Now I didn't want to write <xsl:text>&#x0a;</xsl:text>
> > for every line feed, so I decided to use an entity instead.
> > That is, I added 
> > <!DOCTYPE xsl:stylesheet [
> >   <!ENTITY LF '<xsl:text>&#x0a;</xsl:text>'>
> > ]>
> > to the stylesheet.
> > 
> > Unfortunately libxml seems to have a problem with the namespace, used
> > in the entity:
> [...]
> > When I call xsltproc I get
> > Entity: line 1: warning: Namespace prefix xsl is not defined
> > <xsl:text>
> >         ^
> [...]
> > One can get around this problem by defining the namespace within the 
> > entity (<!ENTITY LF '<xsl:text xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>&#x0a;</xsl:text>'>).
> [...]
> > >From my understanding of entities, I would expect xalans behaviour to
> > be correct, in which case libxml had a bug here.
> > But I don't know enough about entities and namespaces to be sure about
> > that.
> 
>   This is a libxml2 bug. In theory, entities should be handled as pure
> input include mechanisms. libxml2 tries to factorize them and will 
> try to build a subtree from an entity. This work well unless you have
> undefined namespace in entities.
>   Consider:
>      <p xmlns:xsl="foo">&LF;</p>
>      <p xmlns:xsl="bar">&LF;</p>
> The trees build from the same entity can be completely different in that
> case. So far libxml simply detect the construct and warn against it. Seems
> in the case of an XSLT processing this can become nasty.

Ok. That's what I suspected.

> Defining entities referencing to undefined namespaces is nasty, it used
> to broke other DOM implementations too. I'm not sure an easy fix can be done.
> I tend to think that fixing those entities is actually in the users
> own interest...
> 
>   Let's say it's a supported bug, I may end up fixing it but you're the
> second one to raise it (after Norm Walsh) and I'm not still convinced it
> should really be fixed :-)
> 
It's ok for me, if you don't fix it (at least for my current usage).
Since one can declare the namespace in the entity itself it's easy to work
around.
OTOH this might be considered a compatibility issue (stylesheets developed
for other xslt engines might break when one switches to libxslt).

Above all I suggest to document such an issue
(preferable both for libxml and libxslt).
If you think bugzilla is the right place for this I can enter bug reports
(basically my mail and your answer), but if this going to be a long term
issue, it might be better to add a 'known bugs' section to the docu and/or
manpages also (I'd volunteer for adding this issue).
As far as bugzilla is concerned, it might be a good idea to provide
links to list of open bugs only instead of all, from the libxml
web pages.
I know, people tend to ignore documentation, and I admit that I didn't
look for this bug in bugzilla either (but it's not there; I looked
now), but since this is a standard violation, I think it should be
documented anyway.

thanks & greetings
       Morus



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]