How to import a text file?

T

toplure

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.
 
A

Arto V. Viitanen

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.
 
P

Philippe Poulard

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.
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 
A

Arto V. Viitanen

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.
 
P

Philippe Poulard

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
--
Cordialement,

///
(. .)
-----ooO--(_)--Ooo-----
| Philippe Poulard |
-----------------------
 

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
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top