How to import a text file?

toplure

Usenet Archive
Joined
Sep 17, 2003
Messages
3
Reaction score
0
In my XML file, there is a section like this:
<Text ID="pos1" href="Text/2-1.txt"/>
<Image ID="pos2" href="Image/kawa.jpg"/>
I want to imoprt the text file the "href" attribute indicate and display the text and image in a same page. That is to say, implements same function as the image. Any suggestions to me? Any suggestion is welcome. Thanks a lot.
 

Arto V. Viitanen

Usenet Archive
Joined
Oct 2, 2002
Messages
39
Reaction score
0
toplure> In my XML file, there is a section like this:

toplure> <Text ID="pos1" href="Text/2-1.txt"/>
toplure> <Image ID="pos2" href="Image/kawa.jpg"/> I

toplure> want to imoprt the text file the "href" attribute indicate and toplure> display the text and image in a same page. That is to say, toplure> implements same function as the image. Any suggestions to me? Any toplure> suggestion is welcome. Thanks a lot.

Since you are not telling us what application you handling your XML-documents, it is hard to tell. But, if you are using XSLT, you might like to check document function, like

<xsl:apply-templates select="document(@href)"/>

or

<xsl:value-of select="document(@href)"/>

if you don't have to evaluate the file.
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
Arto said:
toplure> <Text ID="pos1" href="Text/2-1.txt"/>

<xsl:apply-templates select="document(@href)"/>

or

<xsl:value-of select="document(@href)"/>

if you don't have to evaluate the file.

hi,

I think that this won't work, because the document function deals with XML documents only; so a text file should cause an error.
 

Arto V. Viitanen

Usenet Archive
Joined
Oct 2, 2002
Messages
39
Reaction score
0
Philippe> I think that this won't work, because the document function Philippe> deals with XML documents only; so a text file should cause an Philippe> error.

You are right. I have used document with XML-files only, so I did not remember.
 

Philippe Poulard

Usenet Archive
Joined
Dec 20, 2001
Messages
412
Reaction score
0
Arto said:
Philippe> I think that this won't work, because the document function Philippe> deals with XML documents only; so a text file should cause an Philippe> error.

You are right. I have used document with XML-files only, so I did not remember.

however, it is possible to use the document function anyway, by plugging an appropriate URIResolver to the XSLT processor; this one should react on a particular adressing form such as :
text:iso-8859-1:/path/to/file/or/url
then the resolver would read the designated file and put it in a text node to return as a DOMSource i did it, it works fine !

the new XSLT 2.0 spec should enhance the document function in this way :
unparsed-text($href as string?, $encoding as xs:string) as string
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,223
Members
248,131
Latest member
Tonypshaw1

Latest Threads

Top