[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: importing from txt file

Subject: Re: importing from txt file
From: john wa <jonni@xxxxxxxxx>
Date: Mon, 3 Sep 2001 16:35:54 +0200 (MEST)
xsl import text 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?
> 
> 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

this is nearly what i wanted but then i have the problem that i don't know
what the file is until half way through the processing.

my situation is that i have an xml file which has a reference to another
file which is plain text. when i output pages (to html) i need this text file to
be included.

so i have xml similar to

<file name="wibble.zip" txt="wibble.info"/>
<file name="wobble.zip" txt="wobble.info"/>
...

if every file had the same description, in my xsl i would just create a
CDATA section...

<![CDATA[
A bit of text where output is escaped
]]>


but because the txt is different for each file i would like

<xsl:copy-of select="document(@txt)" />

but somehow say that this document is all CDATA, and that there's no tags.

i'm using the gnome xsl library from perl so i can't do any funky java with
it :(

i hope this makes the problem clearer :)

-- 
Sent through GMX FreeMail - http://www.gmx.net

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.