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