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 ma...@xraymedia.com on 2002/02/08 21:43:25 UTC
http://java.sun.com/xml/jaxp/faq.Parsing XML-file with large CData sec
I had downloaded JAXP Winter Pack on Debian Linux.
I have JDK1.2.2
I use an XML file with very large CData sections( that keep SQL text ).
DocumentBuilderFactory factory =
DocumentBuilderFactory.newInstance();
.......................
File f = new File("some_file.xml");
DocumentBuilder builder = factory.newDocumentBuilder();
xmlConfig= builder.parse(f);
...........................................
When I find node, that contain <![CDATA[....big...big SQL,many lines ]]>
NodeList textChildren = ndSQL.getChildNodes();
Node dataNode;
for (int j = 0; j<textChildren.getLength();j++){
dataNode = textChildren.item(j);
switch (dataNode.getNodeType()) {
case Node.CDATA_SECTION_NODE:
System.out.print( dataNode.getNodeValue() );
break;
case Node.TEXT_NODE:
System.out.print( dataNode.getNodeValue() );
break;
}
}
getNodeValue of corresponding CDataSection returns only first
line!("select.."), its getLength() returns 9(!);
and when I print whole DOM tree, using something like:
.........................................
TransformerFactory tFactory =
TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer();
DOMSource source = new DOMSource(xmlConfig);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
..................................,
I see, that EACH CData section is stripped:
<![CDATA[only first line... ]]>
Actually, these code snippets - only from testing module;
that was used in servlet to serve requests for data; and output to
httpResponse; but the fact is that during parsing, each CDATA section is
stripped.
I am quite unhappy of this.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org