1 /* 2 * saxfilter.h 3 * 4 * 5 * Created by Andreas Vox on 21.09.06. 6 * Copyright 2006 under GPL2. All rights reserved. 7 * 8 */ 9 10 #include "uniqueid.h" 11 begin(const Xml_string & tag,Xml_attr attr)12void UniqueID::begin(const Xml_string& tag, Xml_attr attr) 13 { 14 if (m_level > 0) // skip mode 15 ++m_level; 16 else 17 { 18 Xml_attr::iterator it = attr.find("id"); 19 if (it != attr.end() && m_seenIDs.find(Xml_data(it)) != m_seenIDs.end()) 20 { 21 // enter skip mode 22 m_level = 1; 23 // replace with <tag idref="seenid" /> 24 Xml_attr idattr; 25 idattr["idref"] = Xml_data(it); 26 SaxFilter::begin(tag, idattr); 27 SaxFilter::end(tag); 28 } 29 else 30 { 31 if (it != attr.end()) 32 m_seenIDs.insert(Xml_data(it)); 33 SaxFilter::begin(tag, attr); 34 } 35 } 36 } 37 38 end(const Xml_string & tag)39void UniqueID::end(const Xml_string& tag) 40 { 41 if (m_level > 0) // skip mode 42 --m_level; 43 else 44 SaxFilter::end(tag); 45 } 46 chars(const Xml_string & text)47void UniqueID::chars(const Xml_string& text) 48 { 49 if (m_level == 0) 50 SaxFilter::chars(text); 51 } 52