Include Files in XML?

M

Michael

I've searched and searched and can't seem to find an answer.

With .shtml you would put <!--#include virtual="/top.shtml">

With .php you would put <?php require 'top.php'?>

But what would I use for XML pages? Is there a similar command and if so what is it?
 
E

Evan Webb

http://www.w3.org/TR/xinclude/

I believe is what you're looking for. Of course, whatever parser you're
working with might not support this... Good luck

-Evan

Michael said:
I've searched and searched and can't seem to find an answer.

With .shtml you would put <!--#include virtual="/top.shtml">

With .php you would put <?php require 'top.php'?>

But what would I use for XML pages? Is there a similar command and if so
what is it?
 
F

Finnbarr P. Murphy

I've searched and searched and can't seem to find an answer.

With .shtml you would put <!--#include virtual="/top.shtml">

With .php you would put <?php require 'top.php'?>

But what would I use for XML pages? Is there a similar command and if so what is it?

One way is to use general entities. See the following article
for an example:

www-106.ibm.com/developerworks/xml/library/x-tipgentity.html

- Finnbarr
 
M

Michael

www-106.ibm.com/developerworks/xml/library/x-tipgentity.html

I tried what it said in there and put the following into a .xml file

-----------------------------------------------------

<?xml version="1.0"?>
<!DOCTYPE letter [
<!ENTITY feed SYSTEM "/rss.xml">
]>

&feed;

-------------------------------------------------------

This is the result I get.

------------------------------------------------------------------------

The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and
then click the Refresh button, or try again later.

Invalid at the top level of the document. Error processing resource
'http://www.mydomain.com/rss.xml'. Line 6, Position 2

&feed

Any ideas as to what I did incorrectly?
 
D

David Carlisle

<?xml version="1.0"?>
<!DOCTYPE letter [
<!ENTITY feed SYSTEM "/rss.xml">
]>

&feed;


Any ideas as to what I did incorrectly?




you can't put the entire document into the entity: you have to have at least
the top level element in your main file

Make that


<?xml version="1.0"?>
<!DOCTYPE letter [
<!ENTITY feed SYSTEM "/rss.xml">
]>
<letter>
&feed;
</letter>

and (probably) don't have <letter>i n your rss.xml file.

David
 
S

Shmuel (Seymour J.) Metz

on 08/20/2004 said:
Any ideas as to what I did incorrectly?

Your res.xml file is not in the expected directory. Try specifying a
relative path or a full path.

--
Shmuel (Seymour J.) Metz, SysProg and JOAT <http://patriot.net/~shmuel>

Unsolicited bulk E-mail subject to legal action. I reserve the
right to publicly post or ridicule any abusive E-mail. Reply to
domain Patriot dot net user shmuel+news to contact me. Do not
reply to (e-mail address removed)
 
M

Michael

<!DOCTYPE letter [
<!ENTITY feed SYSTEM "/rss.xml">
]>
<letter>
&feed;
</letter>

Ok that now seems to work fine thanks :)

However, now another problem persist. What my goal was is to take a
very long url and turn it into rss.xml (its a RSS feed).

If I open up the rss.xml file in a browser with that code, it shows up
fine, shows the rss file, and all is dandy.

However it won't validate in the rss validator, the validator shows
the following:

<?xml version="1.0"?><!DOCTYPE letter [
<!ENTITY feed SYSTEM "/reallybiglongfile.xml">
]>
<letter>
&feed;
</letter>

As oppose to the actual xml file that shows in the browser with the
RSS feed that I want it to display. Any ideas how to solve the
problem?
 
N

Nomad

Try Using
<include xlink:href="fileName.fileType">

This is a problem I had encountered in the passed and using the xlin
worked for me


-
Noma
 

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

Forum statistics

Threads
473,997
Messages
2,570,241
Members
46,831
Latest member
RusselWill

Latest Threads

Top