[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Can I suppress entity substitution in XSLT?


Subject: RE: [xsl] Can I suppress entity substitution in XSLT?
From: "Andrew Welch" <AWelch@xxxxxxxxxxxxxxx>
Date: Mon, 28 Jul 2003 11:35:55 +0100

> 1. Remove the problem from XSLT's scope altogether. Use a post-processing
> routine, such as a Perl or Python script, or sed, to perform substitutions
> of characters with named entities in the output files after the XSLT
> processor writes them. Maintaining the well-formedness of your output is
> your concern.
> 
> 2. Hack the serializer. You could thus extend XSLT with, for example, a
> custom output method. Your serializer would intercept characters you
> wanted
> to represent with entities, and take care of the escaping. Back when James
> Clark's XT was the de-facto reference implementation for XSLT, he
> demonstrated how to do something not unlike this.
> 
> 3. Drive the serializer from within XSLT. Perhaps considered by some to be
> bad form since it crosses the line between XSLT processing and
> serialization, you can nonetheless do this with the optional
> disable-output-escaping feature, if you have it (it's available in Xalan).
> I'd call this a legitimate use of d-o-e, assuming of course you understand
> this kind of processing is limited in its application (a) to scenarios
> where file-writing is part of the pipeline, and (b) in the engines it will
> work on -- i.e., it's not as portable as XSLT generally. For this reason
> and others, you may want to implement this in a separate stylesheet from
> your main transform, and run it as the terminal process in a chain.

Just to add:

4.  (iirc) You can implement your own EntityResolver() in java, and then set the parser to look there to resolve entities.  This gives you control of what gets passed back, so I think you can just pass back the entity reference.  I'm not too sure how you would get on further down the chain - I used this a while back to parse lots of xml that refencened dtd's that were unreachable (can't remember why offhand...) but its nice because it's all done with java (no nasty separate text processing stuff :) 

http://java.sun.com/j2se/1.4.1/docs/api/org/xml/sax/EntityResolver.html

andrew

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.502 / Virus Database: 300 - Release Date: 18/07/2003
 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords