Re: [xml] Text-Entities and Namespaces?

On Fri, Jan 11, 2002 at 03:52:38PM +0100, Morus Walter wrote:

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
One can get around this problem by defining the namespace within the 
entity (<!ENTITY LF '<xsl:text xmlns:xsl="";>&#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

  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.
     <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.
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 :-)


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml Gnome XML XSLT toolkit | Rpmfind RPM search engine

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