Making entities available to multiple XML documents

M

Matthew Burgess

I'm not sure that XML allows me to do what I want, but here goes:

Given that I have files a.xml and b.xml who both need to access an
entity defined in c.ent how do I go about it?

Ideally I'd like a syntax similar to:

--- a.xml (or b.xml) ---
<!DOCTYPE ... [
#include c.ent <!-- makes all entities in c.ent available in a.xml
-->
]>

&c-ent;
--- end xml file ---

--- c.ent ---
<!ENTITY c-ent "entity from c.ent">
--- end c.ent ---

Any ideas if/how I can achieve this without putting the entities
within the DTD itself (which is not an option)?

Thanks,

Matt.
 
T

Toni Uusitalo

Matthew Burgess said:
I'm not sure that XML allows me to do what I want, but here goes:

Given that I have files a.xml and b.xml who both need to access an
entity defined in c.ent how do I go about it?

Ideally I'd like a syntax similar to:

--- a.xml (or b.xml) ---
<!DOCTYPE ... [
#include c.ent <!-- makes all entities in c.ent available in a.xml
-->
]>

Hmmm. maybe I don't understand your goal or maybe I'm underestimating your
XML skills, but isn't external DTD (that will contain your entity
declarations) enough?

<!DOCTYPE rootname SYSTEM "external.dtd">

external DTD:

<!ENTITY name1 "value1">
<!ENTITY name2 "value2">


Toni Uusitalo
 
M

Matthew Burgess

Toni Uusitalo said:
Matthew Burgess said:
I'm not sure that XML allows me to do what I want, but here goes:

Given that I have files a.xml and b.xml who both need to access an
entity defined in c.ent how do I go about it?

Ideally I'd like a syntax similar to:

--- a.xml (or b.xml) ---
<!DOCTYPE ... [
#include c.ent <!-- makes all entities in c.ent available in a.xml
-->
]>

Hmmm. maybe I don't understand your goal or maybe I'm underestimating your
XML skills, but isn't external DTD (that will contain your entity
declarations) enough?

<!DOCTYPE rootname SYSTEM "external.dtd">

external DTD:

<!ENTITY name1 "value1">
<!ENTITY name2 "value2">


Toni Uusitalo

I managed to do it this way:

--- a.xml/b.xml --
<!DOCTYPE ... [
<!ENTITY % c-entities SYSTEM "path/to/c.ent">
%c-entities;
]>
<!-- a.xml/b.xml can now use any entity defined in c.ent -->
--- end a.xml/b.xml ---

Thanks,

Matt.
 
T

Toni Uusitalo

I managed to do it this way:

--- a.xml/b.xml --
<!DOCTYPE ... [
<!ENTITY % c-entities SYSTEM "path/to/c.ent">
%c-entities;
]>
<!-- a.xml/b.xml can now use any entity defined in c.ent -->
--- end a.xml/b.xml ---

Yes, it was parameter entities was what you were after, BTW W3C has
http://www.w3.org/2003/entities page which contains a lot of entity
definitions for XML/XHTML.

Toni Uusitalo
 

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,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top