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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
XML

From novice to tech pro — start learning today.