DTD's in external Entities?

Binesh Bannerjee binesh at hex21.com
Thu Aug 26 00:14:55 BST 1999


Woo hoo, I'm finally off the edge and have dove into the world
of XML/DOM etc... I have a question tho...


Here's what I want to do:
	I want to have a document "container.xml"

	<?xml version="1.0" standalone="no" ?>
	<!DOCTYPE container [
		<!ELEMENT container ANY>
		<!ENTITY blah SYSTEM "blah.xml">
	]>

	<container>
		&blah;
	</container>


then,
	blah would contain:
	<?xml version="1.0" standalone="yes" ?>
	<!DOCTYPE data [
		<!ELEMENT data (firstname,lastname)>
		<!ELEMENT firstname (#PCDATA)>
		<!ELEMENT lastname (#PCDATA)>
	]>
	<data>
		<firstname>Binesh</firstname>
		<lastname>Bannerjee</lastname>
	</data>

I'm using Sun's DOM implementation... If I'm not misinterpreting, Listing
6-17 in "XML: Extensible Markup Language" by Elliotte Rusty Harold on page
202 does exactly that...

If I run Sun's
	XmlDocument.createXmlDocument("file:///path/blah.xml",true);

works fine...
However
	running XmlDocument.createXmlDocument("file:///path/container.xml",true);

yields:
	org.xml.sax.SAXParseException: Expected "encoding=...".
        at com.sun.xml.parser.Parser.fatal(Parser.java:2797)

Removing the xml PI from blah.xml (which makes it an invalid doc, if I've
read the spec correctly) yields:
	org.xml.sax.SAXParseException: The content beginning "<!" is not legal markup. Perhaps the "!" (&#21;) character should be a letter.
        at com.sun.xml.parser.Parser.fatal(Parser.java:2797)

What's going on?
	Shouldn't I be able to do this? If I remove the &blah; in
container.xml it parses fine... If not, what is the best way of doing
what I want? Even this fails:
	blah.dtd:
		<!ELEMENT data (firstname,lastname)>
		<!ELEMENT firstname (#PCDATA)>
		<!ELEMENT lastname (#PCDATA)>

	blah.xml:
		<?xml version="1.0" standalone="no"?>
		<!DOCTYPE data SYSTEM "blah.dtd">
		<data>
			<firstname>Binesh</firstname>
			<lastname>Bannerjee</lastname>
		</data>
	container.xml:
		<?xml version="1.0" standalone="no"?>
		<!DOCTYPE container [
			<!ELEMENT container ANY>
			<!ENTITY blah SYSTEM "blah.xml">
		]>
		<container>
			&blah;
		</container>

How does one include _valid_ xml docs in other _valid_ xml docs??
Am I doing something wrong, or is it time to switch DOM implementations?

Thanks...
Binesh Bannerjee


xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)





More information about the Xml-dev mailing list