This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: importing from txt file


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]