XML external entity

Hi,

I'm trying to use XML external entities to split up a configuration file (server.xml) but am having real difficulty with external entities that load other external entities and how to achieve that.

Due to the setup, I need 3 levels of XML files:

1. server.xml - This is the top level file and includes the contents of instance.xml
2. instance.xml - This file needs to include multiple external entities...
3. Individual xml files

My files like like this (see code section).


But every time I get the following error:

SEVERE: Parse Fatal Error at line 2 column 10: A DOCTYPE is not allowed in content

I take this to mean that instance.xml cannot include a DOCTYPE - but then how can I specify an ENTITY tag in there?

Thanks.

************* SERVER.XML *****************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE GlobalNamingResources[
        <!ENTITY includes SYSTEM "instance.xml" >
]>
<GlobalNamingResources>
       &includes;
</GlobalNamingResources>
 
 
 
************* INSTANCE.XML *****************
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Context[
        <!ENTITY authenticate SYSTEM "/usr/local/tomcat/applications/Production/authenticate.xml">
        <!ENTITY ipsec SYSTEM "/usr/local/tomcat/applications/Production/ipsec.xml">
]>
&authenticate;
&ipsec;
 
 
 
************* AUTHENTICATE.XML *****************
<?xml version="1.0" encoding="UTF-8"?>
 
<Resource name="jdbc/authenticate"
auth="Container"
type="javax.sql.DataSource" />

Open in new window

LVL 2
Office-ShadowAsked:
Who is Participating?
 
abelCommented:
You will be out of luck here, using entities is not gonna help you out. But, as it often goes, this problem was noted by the W3C and they created a new specification (yippeee!) which can help us with splitting XML in manageable chunks: XInclude http://www.w3.org/TR/xinclude/.

Compared to other W3C standards it is rather short. There are already quite some implementations and XSLT processors, for one, know how to work with it. A heads-up on the technique is found here: http://cafe.elharo.com/xml/xinclude/.

Sorry that I don't have better news for you then just "use something else"....
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.