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/09/18 22:54:04 UTC
DO NOT REPLY [Bug 12789] New: -
CDATA BUG
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=12789>.
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=12789
CDATA BUG
Summary: CDATA BUG
Product: Xerces2-J
Version: 2.0.0
Platform: All
OS/Version: Windows NT/2K
Status: NEW
Severity: Minor
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: svenkatesh_s@yahoo.com
It seems that if an xml document which is in the form of a string contains
2 cdata elements then it could not be converted into a document object if we
used the following code
Example XML Data :
<Parent>
<Element1>
<![CData[ Ele1 ]]>
</Element1>
<Element2>
<![CData[ Ele2 ]]>
</Element2>
</Parent>
Probelmatic code :
String xmlString //this contains the whole XML data as a string.
TransformerFactory tf = TransformerFactory.newInstance();
Transformer _transformer = tf.newTransformer();
DOMSource domSource = new DOMSource(doc);
Document doc = (Document)dom.getNode();
StringWriter XMLdata = new StringWriter();
StreamResult result = new StreamResult(XMLdata);
_transformer.transform(domSource, result);
String dir = "C:/tempresults";
String xml_String = xmlString;
java.io.PrintStream pStream =
new java.io.PrintStream(
new java.io.FileOutputStream(
new java.io.File(dir + "/" + "sub_msg_.xml")));
pStream.println(xml_String);
pStream.close();
}catch(Exception ex) {
ex.printStackTrace();
}
But the following code seems to work;
javax.xml.parsers.DocumentBuilderFactory dbf =
javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder db = dbf.newDocumentBuilder();
StringReader _inputString = new StringReader(xmlString);
this.doc = db.parse(new org.xml.sax.InputSource(_inputString));
StringWriter XMLdata = new StringWriter();
StreamResult result = new StreamResult(XMLdata);
_transformer.transform(domSource, result);
String dir = "C:/tempresults";
String xml_String = xmlString;
java.io.PrintStream pStream =
new java.io.PrintStream(
new java.io.FileOutputStream(
new java.io.File(dir + "/" + "sub_msg_.xml")));
pStream.println(xml_String);
pStream.close();
Can any one tell me why the document is not build correctly
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org