Re: [xsl] character entities

Subject: Re: [xsl] character entities
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Tue, 20 Nov 2001 15:56:00 +0000

> so... what I'd like (Mike:-) is for the entities to get expanded on
> the way in, but to have some markers in the stream so I can fold
> them up on the way out. (You can do this by hand by editing the dtd
> to add pi's at the beginning and end of every entity definition, but
> it's a bit of a pain.

That's kind of what I was talking about with the substitution with
element on parse of the source document. If you had:

  <doc>... &e04BL-a; ...</doc>

in your source, and then you had a stylesheet with a flag that said
'include the entity references as elements' then the stylesheet would

  <doc>... <phys:entity-ref name="e04BL-a">...</phys:entity-ref> ...</doc>

You could get access to the content of the phys:entity-ref; most
importantly, the string value of the doc element would be the same as
if the entity were naturally expanded, and you could have a template
that went:

<xsl:template match="phys:entity-ref">
  <xsl:entity-ref name="{@name}" />

to create the entity reference on output (assuming that's what
xsl:entity-ref does).

The trouble is that your lovely logic about the children of the doc
element needs to extend to cover grandchildren within the
phys:entity-ref element as well. That's the advantage with using PIs -
children are still children - but then the logic of wrapping up the
entity again is complicated. Either you have to do the wrapping up in
the stylesheet (which is messy) or the processor has to do it (which
is risky as it would be easy to forget the 'end' PI).

And of course neither works with entity references within attribute



Jeni Tennison

 XSL-List info and archive:

Current Thread