XML external entity

Posted on 2009-02-23
Last Modified: 2012-05-06

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?


************* SERVER.XML *****************

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE GlobalNamingResources[

        <!ENTITY includes SYSTEM "instance.xml" >





************* 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.XML *****************

<?xml version="1.0" encoding="UTF-8"?>

<Resource name="jdbc/authenticate"


type="javax.sql.DataSource" />

Open in new window

Question by:Office-Shadow
    1 Comment
    LVL 39

    Accepted Solution

    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

    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:

    Sorry that I don't have better news for you then just "use something else"....

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now