use of org.w3c.dom.CDATASection in project j2objc by google.
the class DOMBuilder method cdata.
/**
* Receive notification of cdata.
*
* <p>The Parser will call this method to report each chunk of
* character data. SAX parsers may return all contiguous character
* data in a single chunk, or they may split it into several
* chunks; however, all of the characters in any single event
* must come from the same external entity, so that the Locator
* provides useful information.</p>
*
* <p>The application must not attempt to read from the array
* outside of the specified range.</p>
*
* <p>Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating
* parsers must do so).</p>
*
* @param ch The characters from the XML document.
* @param start The start position in the array.
* @param length The number of characters to read from the array.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
public void cdata(char[] ch, int start, int length) throws org.xml.sax.SAXException {
if (isOutsideDocElem() && org.apache.xml.utils.XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
// avoid DOM006 Hierarchy request error
return;
String s = new String(ch, start, length);
CDATASection section = (CDATASection) m_currentNode.getLastChild();
section.appendData(s);
}
use of org.w3c.dom.CDATASection in project nutch by apache.
the class DOMBuilder method cdata.
/**
* Receive notification of cdata.
*
* <p>
* The Parser will call this method to report each chunk of character data.
* SAX parsers may return all contiguous character data in a single chunk, or
* they may split it into several chunks; however, all of the characters in
* any single event must come from the same external entity, so that the
* Locator provides useful information.
* </p>
*
* <p>
* The application must not attempt to read from the array outside of the
* specified range.
* </p>
*
* <p>
* Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating parsers must
* do so).
* </p>
*
* @param ch
* The characters from the XML document.
* @param start
* The start position in the array.
* @param length
* The number of characters to read from the array.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
*/
public void cdata(char[] ch, int start, int length) throws org.xml.sax.SAXException {
if (isOutsideDocElem() && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
// avoid DOM006 Hierarchy request error
return;
String s = new String(ch, start, length);
// XXX ab@apache.org: modified from the original, to accomodate TagSoup.
Node n = m_currentNode.getLastChild();
if (n instanceof CDATASection)
((CDATASection) n).appendData(s);
else if (n instanceof Comment)
((Comment) n).appendData(s);
}
use of org.w3c.dom.CDATASection in project nutch by apache.
the class DOMBuilder method cdata.
/**
* Receive notification of cdata.
*
* <p>
* The Parser will call this method to report each chunk of character data.
* SAX parsers may return all contiguous character data in a single chunk, or
* they may split it into several chunks; however, all of the characters in
* any single event must come from the same external entity, so that the
* Locator provides useful information.
* </p>
*
* <p>
* The application must not attempt to read from the array outside of the
* specified range.
* </p>
*
* <p>
* Note that some parsers will report whitespace using the
* ignorableWhitespace() method rather than this one (validating parsers must
* do so).
* </p>
*
* @param ch
* The characters from the XML document.
* @param start
* The start position in the array.
* @param length
* The number of characters to read from the array.
* @see #ignorableWhitespace
* @see org.xml.sax.Locator
* @throws org.xml.sax.SAXException if text is found before
* the document element
*/
public void cdata(char[] ch, int start, int length) throws org.xml.sax.SAXException {
if (isOutsideDocElem() && XMLCharacterRecognizer.isWhiteSpace(ch, start, length))
// avoid DOM006 Hierarchy request error
return;
String s = new String(ch, start, length);
// XXX ab@apache.org: modified from the original, to accomodate TagSoup.
Node n = m_currentNode.getLastChild();
if (n instanceof CDATASection)
((CDATASection) n).appendData(s);
else if (n instanceof Comment)
((Comment) n).appendData(s);
}
use of org.w3c.dom.CDATASection in project zm-mailbox by Zimbra.
the class W3cDomUtil method toFlattened.
private static Element toFlattened(Node node, ElementFactory factory) {
Element elt = factory.createElement(dom4jQNameForNode(node));
makeAttributes(elt, node);
StringBuilder content = new StringBuilder();
for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
switch(child.getNodeType()) {
case Node.ELEMENT_NODE:
// i.e. add textual representation of the XML
content.append(W3cDomUtil.asXML(child, false));
break;
case Node.TEXT_NODE:
content.append(child.getNodeValue());
break;
case Node.CDATA_SECTION_NODE:
CDATASection cdata = (CDATASection) child;
content.append(cdata.getData());
break;
}
}
return elt.setText(content.toString());
}
use of org.w3c.dom.CDATASection in project pmd by pmd.
the class RuleSetWriter method createCDATASectionElement.
private Element createCDATASectionElement(String name, String value) {
Element element = document.createElementNS(RULESET_2_0_0_NS_URI, name);
CDATASection cdataSection = document.createCDATASection(value);
element.appendChild(cdataSection);
return element;
}
Aggregations