Re: [xsl] Supressing entity expansion during XSLT transform

Subject: Re: [xsl] Supressing entity expansion during XSLT transform
From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx>
Date: Fri, 11 Jan 2008 12:51:33 +0530
Thanks Ken for the useful explanation.

I am trying to use Saxon 9 extension, saxon:character-representation
(with value, entity). But I am having problem with getting the output
right. Could somebody, please help me with this.

On Jan 11, 2008 10:37 AM, G. Ken Holman <gkholman@xxxxxxxxxxxxxxxxxxxx> wrote:
> At 2008-01-11 10:29 +0530, Mukul Gandhi wrote:
> >[1] I want to write a transform which prevents entity expansion.
>
> The XPath data model on which XSLT is built does not represent entity
> references so that any present in the input source tree cannot be
> preserved for serialization in the output tree.  Since the result
> tree is based on the XPath data model, one cannot represent an entity
> reference in the result tree as a data model abstraction.
>
> If you want to create entity references in the result file using XSLT
> 2.0, you can play with serialization using xsl:output-character and
> compose entity references, but since you don't know where the entity
> references were in the source tree, you won't know where to compose
> them in the output serialization.
>
> >For
> >e.g. the output of transform should be (this is an identity
> >transform):
> >
> ><?xml version="1.0"?>
> ><!DOCTYPE root [
> >   <!ENTITY x "hello">
> >]>
> ><root>
> >   <a>&x; world</a>
> ></root>
> >...
> >I get the output:
> >
> ><?xml version="1.0" encoding="UTF-8"?>
> ><root>
> >   <a>hello world</a>
> ></root>
>
> That is because that is the information found in the source
> tree.  The XML processor in the XSLT processor has already resolved
> all aspects of syntax and has built the XPath node tree with the
> information found in the source file (but not the syntax found in the
> source file).
>
> Constructs such as entity references and CDATA sections are merely
> aspects of syntax, not of information.
>
> >But I want the output as specified in [1] above.
> >
> >What is the solution to this problem?
>
> Using a language other than XSLT.  I believe the DOM supports entity
> references.
>
> >I can use XSLT 2.0.
>
> Not for this problem you can't.
>
> I hope this helps.
>
> . . . . . . . . . . . . Ken


-- 
Regards,
Mukul Gandhi

Current Thread