This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: importing from txt file
- To: xsl-list at lists dot mulberrytech dot com
- Subject: Re: [xsl] importing from txt file
- From: Oleg Tkachenko <olegt at multiconn dot com>
- Date: Mon, 03 Sep 2001 13:49:39 +0200
- Organization: Multiconn International
- References: <18797.999511407@www39.gmx.net>
- Reply-To: xsl-list at lists dot mulberrytech dot com
john wa wrote:
> in my xsl i need to reference an external document which is a text file.
>
> i try to do something like <xsl:copy-of select="document('eg.txt')/" />
> but obviously, because eg.txt isn't an xml file it won't work. is there
> another way to import a file but treat the whole file as CDATA?
>
> thanks.
>
>
You can use xml's external entities, e.g. place at the prolog of your
stylesheet entity declaration:
<!DOCTYPE xsl:stylesheet [
<!ENTITY text SYSTEM "file://c:\text.txt">
]>
and then in a template you can output it this way:
<xsl:text>&text;</xsl:text>
But be warned: non-validating xml parser may not resolve external
entities at all, in fact ie5 does resolving but mozilla doesn't.
--
Oleg Tkachenko
Multiconn International
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list