Re: [xslt] Not expanding entities



On Wed, Feb 20, 2002 at 12:49:30AM -0600, Brent M Hendricks wrote:
> I need an xslt processor that passes character entities in the 
> stylesheet on unexpanded into the output, so I started poking around in 
> the source to xsltproc.  Lo and behold, I found the line:

  That's a serious problem: it's incompatible with the XPath data model
XSLT is built upon ! XPath requires entities to be subtitued, and the
libxml2 XPath engine expect this (and changing the XPath engine to 
accept the entities while keeping the correct behaviour would be
really really hard).

> /*
>   * Replace entities with their content.
>   */
> xmlSubstituteEntitiesDefault(1);
> 
> so I tried changing it to a 0.  Unfortunately, this caused xsltproc to 

  Bad idea because doing it that way you also change the way the
processor loads the target documents, not only the stylesheets.

> choke on my stylesheet with the message:
> 
> xsltParseTemplateContent: xslt:text content problem

  Right the XSLT processor expects to run without seing any entities.

> I tracked this down to xslt.c in xsltParseTemplateContent() where it is 
> parsing the xslt:text nodes:
[...]
> Is there any reason why entity ref nodes aren't allowed here?  I tried 
> adding them to the test and that got rid of the error, but it didn't 
> make xsltproc pass the entities.  My guess is that they would need to be 
> processed differently in the code that follows this check.  Perhaps 
> rather than using its children it would just use its content?

  Well, there is a number of places in the code where the stylesheet content
may be manipulated during processing, this could be as simple a just doing
copies of nodes and subtrees, but also running XPath queries on variable
values etc.. inherited from the stylesheet content. Doing it properly
would require changing the XPath engine radically. You can try to locate
the parts where the expected processing of entities diverges from what 
you expect by running withy the -v flag and examining the output. Then try
to patch those parts to accept processing of entities nodes.

Daniel

-- 
Daniel Veillard      | Red Hat Network https://rhn.redhat.com/
veillard@redhat.com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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