Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

XML external entity

Posted on 2009-02-23
1
Medium Priority
?
555 Views
Last Modified: 2012-05-06
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

0
Comment
Question by:Office-Shadow
1 Comment
 
LVL 39

Accepted Solution

by:
abel earned 2000 total points
ID: 23712080
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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) 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.
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

810 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