Xerces-C++ ContentHandler::characters()の動作

Xerces-C++ 2.8のSAXで発生した問題に関するメモ。

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.

http://xerces.apache.org/xerces-c/apiDocs-3/classContentHandler.html

1つの要素であっても、複数回caracters()がCallされる場合がある。
確認した限りでは、CDATAセクションが複数存在する場合、および&等があるとそこでデータを区切って複数回caracters()がCallされる。

ということで、characters()内で取得した内容をそのままデータに詰める処理があったため障害が発生した。
ContentHandler派生クラスにデータ収集用のメンバを作成し、characters()内ではメンバの末尾にデータを連結、
endElement()内で収集したデータの処理およびメンバの初期化を実施することで修正。