Re: [xslt] expand entities

On Mon, Jun 03, 2002 at 11:21:43AM +0100, Matt Sergeant wrote:
> Hash: SHA1
> There's a strange interaction between libxslt and libxml2's 
> expandEntitiesDefaultValue flag. If you do XSLT on a stylesheet DOM that 
> hasn't had it's entities expanded, then the entity gets completely dropped.
> You can demonstrate this by changing
>     /*
>      * Replace entities with their content.
>      */
>     xmlSubstituteEntitiesDefault(1);
> to a zero.
> Normally in libxml2, if you do this it leaves entities in-place in the 
> document. But it appears that if you go through XSLT with this, the entities 
> vanish into thin air. As can be seen with the above change to xsltproc, and 
> the following style and xml files:
> <?xml version="1.0" encoding="UTF-8"?>
> <root>foo</root>
> and
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE stylesheet [
> <!ENTITY ouml   "&#246;">
> ]>
> <xsl:stylesheet
>      xmlns:xsl="";
>      version="1.0">
>  <xsl:output method="xml" />
>  <xsl:template match="/">
>   <out>foo&ouml;bar</out>
>  </xsl:template>
> </xsl:stylesheet>
> Is this a bug, or do you just always have to have entity expansion turned on?

  the latter, the XPath engine do not deal with entities references in the
tree so asking the parser to expand the entities is needed. On the other
hand this is doable on a case by case basis without forcing the global
setting to always turn expansion on, this requires to use a lower layer
in the libxml2 parsing API where the user code has access to the parser
context (where the replacement flag can be turned on).


Daniel Veillard      | Red Hat Network  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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