You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by John Horner <Jo...@sas.com> on 2003/03/05 22:33:50 UTC

vanishing text problem

I've run into some strange behavior regarding PCDATA.  The first time I parse my document the DOM gets built exactly as I expect.  The second time I parse the same document my DOM is missing text nodes.  I only see this behavior when I'm using an external DTD and declare at least one external entity.

I don't know if this is a problem with my code, my documents or what.  Has anyone seen anything like this?

I'm using 2.3 with the DOM3 build.  The program (ReproText.java), document (ReproText.xml) and dtd (ReproText.dtd) are pasted below.  Note that the external entity declarations are also missing when we write out the second time.  I also got the same results using DOMBuilderImpl instead of DOMASBuilderImpl.

*************************************** ReproText.java ***************************
public class ReproText {

	public static void main(String[] args) {

		try {

			DOMASBuilderImpl test = new DOMASBuilderImpl();
			Document d = test.parseURI("ReproText.xml");
			DOMWriter writer = new DOMWriterImpl();
			writer.writeNode(System.out, d);

			test = new DOMASBuilderImpl();
			d = test.parseURI("ReproText.xml");
			writer = new DOMWriterImpl();
			writer.writeNode(System.out, d);
		} catch (Exception e) {
			e.printStackTrace();	
		}
	}
}

***********************************  ReproText.xml  **********************************

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE person SYSTEM "ReproText.dtd"
[<!ENTITY e SYSTEM "entity.xml">]>

<person>
	<person-name> me </person-name>
	<person-email> me@here </person-email>
	<other> moreinfo </other>
</person>

***********************************  ReproText.dtd  **********************************
<!ELEMENT person (person-name, person-email, other)>
<!ELEMENT person-name (#PCDATA)>
<!ELEMENT person-email (#PCDATA)>
<!ELEMENT other (#PCDATA)>



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org