Thanks for trying this out. I went back to track the problem in detail and found it was occurring not with the original file, but with a copy that had gone through a text->DOM->text cycle. The problem is actually on the output side, using XMLSerializer. This keeps the entity reference but loses the definition with Xerces 2; with Xerces 1 it just substitutes the entity text directly.

Xerces 2:
<?xml version="1.0" encoding="UTF-8"?>
<spec>&name;</spec>

Xerces 1:
<?xml version="1.0" encoding="UTF-8"?>
<spec>xyzzy</spec>

Here's the *complete* test program:

import java.io.*;
import java.util.*;

import javax.xml.parsers.*;

import org.apache.xerces.dom.*;
import org.apache.xerces.parsers.*;
import org.apache.xml.serialize.*;

import org.w3c.dom.*;

import org.xml.sax.*;

public class Test
{
private static DOMParser m_parser;
private static XMLSerializer m_serializer;
public static void main(String[] argv) {
if (m_parser == null) {
m_parser = new DOMParser();
try {
m_parser.setFeature
("http://xml.org/sax/features/validation";, false);
m_parser.setFeature
("http://apache.org/xml/features/dom/defer-node-expansion";,
true);
m_parser.setFeature
("http://xml.org/sax/features/namespaces";, true);
} catch (Exception ex) {
ex.printStackTrace(System.err);
System.exit(0);
}
}
Object doc = null;
try {
m_parser.parse(new InputSource(new FileReader("test.xml")));
doc = m_parser.getDocument();
m_parser.reset();
System.out.println("Success reading document!");
} catch (Exception ex) {
ex.printStackTrace(System.err);
System.exit(0);
}
if (m_serializer == null) {
OutputFormat format = new OutputFormat((Document)doc);
m_serializer = new XMLSerializer(format);
}
try {
m_serializer.reset();
CharArrayWriter out = new CharArrayWriter();
m_serializer.setOutputCharStream(out);
m_serializer.serialize(((Document)doc).getDocumentElement());
System.out.println(out.toString());
} catch (Exception ex) {
ex.printStackTrace(System.err);
System.exit(0);
}
}
}



Andy Clark wrote:

Dennis Sosnoski wrote:

Here's the code (with classpath including xmlParserAPIs.jar and
xercesImpl.jar):


I'm using your code and I'm still not seeing any problems with the Xerces 2.0.0 release. Is there any other information you could provide about your environment?




--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to