Claudenw commented on code in PR #233: URL: https://github.com/apache/creadur-rat/pull/233#discussion_r1564525024
########## apache-rat-core/src/main/java/org/apache/rat/report/xml/writer/impl/base/XmlWriter.java: ########## @@ -525,24 +548,36 @@ private void writeAttributeContent(CharSequence content) throws IOException { */ @Override public IXmlWriter content(CharSequence content) throws IOException { - if (elementNames.isEmpty()) { - if (elementsWritten) { - throw new OperationNotAllowedException("Root element has already been closed."); - } - throw new OperationNotAllowedException("An element must be opened before content can be written."); - } - if (inElement) { - writer.write('>'); - } - writeBodyContent(content); + prepareForData(); + writeEscaped(content, false); inElement = false; return this; } - private void writeBodyContent(final CharSequence content) throws IOException { - writeEscaped(content, false); + + /** + * Writes content. Calling this method will automatically Note that this method + * does not use CDATA. + * + * @param content the content to write + * @return this object + * @throws OperationNotAllowedException if called before any call to + * {@link #openElement} or after the first element has been closed + */ + @Override + public IXmlWriter cdata(CharSequence content) throws IOException { + prepareForData(); + StringBuilder sb = new StringBuilder(content); + int found; + while (-1 != (found = sb.indexOf("]]>"))) { + sb.replace(found, found+3, "<!- Rat removed CDATA closure here ->"); Review Comment: It was supposed to be a real comment, though it is in the middle of a CDATA block. Perhaps I should have inserted a new CDATA block start after the closure rather than removing the original cdata block. The issure arises when samples from XML document include an ending CDATA tag. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@creadur.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org