Re: [xsl] importing from txt file

Subject: Re: [xsl] importing from txt file
From: Oleg Tkachenko <olegt@xxxxxxxxxxxxx>
Date: Mon, 03 Sep 2001 13:49:39 +0200
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



Current Thread