Character reference reporting from SAX.
Remus Stratulat 2004-06-17
I found myself in the position to work with SAX and to construct some
data structure based on a xml. In the xml there were charactere
references along with other special characters like 鮠I needed to know
when I got each of them so to construct the data structure correctly.
Normally SAX is reporting both in the same way using characters()
method from DefaultHandler. I posted this request of mine on bugzilla
and Neil Graham was kind enough to tel me about this undocumented
feature that SAX has:
http://apache.org/xml/features/scanner/notify-char-refs
Setting this on true will make SAX to report character references the same way as entities. But here is the code:
SAXParser xr = new SAXParser();
try {
xr.setFeature("http://apache.org/xml/features/scanner/notify-char-refs", true);
} catch (Exception e) {
System.out.println("Feature not supported");
}