You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/01/16 18:20:18 UTC
DO NOT REPLY [Bug 5883] New: -
DocumentBuilder parse() produces a mangled Document.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5883>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=5883
DocumentBuilder parse() produces a mangled Document.
Summary: DocumentBuilder parse() produces a mangled Document.
Product: Xerces2-J
Version: 2.0.0 [beta 4]
Platform: PC
OS/Version: Other
Status: NEW
Severity: Blocker
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: dleslie@apache.org
1. Instantate a DocumentBuilder (docBuilder).
2. Call docBuilder.parse() with a String URI.
3. Serialize the Document returned by the parse operation.
In some of the resulting blocks of text (i.e., from individual text nodes), the
final characters in the text block appear at the beginning of the text block.
For example the following text in the Xalan dtm.xml document
<p>The Document Table Model (DTM) is an interface to a Document Model designed
specifically for the needs of our XPath and XSLT implementations. The motivation
behind this model is to optimize performance and minimize storage.</p>
appears as follows when the document is parsed and the resulting Document
serialized:
<p>implementations. The motivation behind this model is to optimize performance
and minimize storage.The Document Table Model (DTM) is an interface to a
Document Model designed specifically for the needs of our XPath and XSLT </p>
Note: This bug appeared when we tried to use StyleBook (updated to call JAXP
rather than Xerces directly) with Xerces-J2beta4 to produce the Xalan-J
documentation.
Here is a simplified example named Test. Check out xml-xalan/java, and run Test
from xml-xalan/java/test.
import org.w3c.dom.Document;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.xalan.serialize.Serializer;
import org.apache.xalan.serialize.SerializerFactory;
import org.apache.xalan.templates.OutputProperties;
import java.io.IOException;
import java.io.FileNotFoundException;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import java.io.FileOutputStream;
public class Test
{
public static void main(String argv[])
throws IOException, SAXException, ParserConfigurationException
{
DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance();
dFactory.setNamespaceAware(true);
DocumentBuilder dBuilder = dFactory.newDocumentBuilder();
Document doc = dBuilder.parse("..\\xdocs\\sources\\xalan\\dtm.xml");
Serializer serializer = SerializerFactory.getSerializer
(OutputProperties.getDefaultMethodProperties("xml"));
serializer.setOutputStream(new FileOutputStream("dtm_out.xml"));
serializer.asDOMSerializer().serialize(doc);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org