You are viewing a plain text version of this content. The canonical link for it is here.
Posted to general@xerces.apache.org by ap...@ca.ibm.com on 2000/03/03 00:37:39 UTC
How to include external XML files?
I have two XML files, one of which tries to include the other. I can't
find the syntax to create a DOM with the included XML appearing.
The main file is:
<?xml version="1.0"?>
<!DOCTYPE testdoc [
<!ELEMENT test(testing)>
<!ELEMENT testing (name)>
<!ELEMENT name (#PCDATA)>
<!ENTITY % local SYSTEM "testing.xml" >
]>
<test>
%local;
</test>
and testing.xml which is to be included in the main:
<?xml version="1.0"?>
<testing>
<name>My Name</name>
</testing>
I read this in as:
DOMParser parser = new DOMParser();
try
{
parser.setFeature( "http://xml.org/sax/features/validation", true);
parser.setFeature(
"http://apache.org/xml/features/dom/defer-node-expansion", false );
parser.setFeature(
"http://apache.org/xml/features/dom/create-entity-ref-nodes", true);
parser.setFeature(
"http://xml.org/sax/features/external-general-entities", true);
parser.setFeature(
"http://xml.org/sax/features/external-parameter-entities", true);
parser.parse( fileName );
} catch (SAXException se) {
System.out.println("sax exception: " + se );
se.printStackTrace();
} catch (IOException se) {
se.printStackTrace();
}
return parser.getDocument( );
thanks,
-adrian.
--
Adrian Powell
apowell@ca.ibm.com