mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-21 06:45:39 -06:00
Core: XML RegisterEntity
git-svn-id: svn://ultimatepp.org/upp/trunk@6072 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
97187d6845
commit
238fbf6c39
4 changed files with 33 additions and 33 deletions
|
|
@ -177,36 +177,18 @@ void XmlParser::Ent(StringBuffer& out)
|
|||
term = t;
|
||||
return;
|
||||
}
|
||||
if(t[0] == 'l' && t[1] == 't' && t[2] == ';') {
|
||||
t += 3;
|
||||
out.Cat('<');
|
||||
}
|
||||
else
|
||||
if(t[0] == 'g' && t[1] == 't' && t[2] == ';') {
|
||||
t += 3;
|
||||
out.Cat('>');
|
||||
}
|
||||
else
|
||||
if(t[0] == 'a')
|
||||
if(t[1] == 'm' && t[2] == 'p' && t[3] == ';') {
|
||||
t += 4;
|
||||
out.Cat('&');
|
||||
const char *b = t;
|
||||
while(*t && *t != ';')
|
||||
t++;
|
||||
if(*t == ';') {
|
||||
int q = entity.Find(String(b, t));
|
||||
if(q >= 0) {
|
||||
out.Cat(entity[q]);
|
||||
term = t + 1;
|
||||
return;
|
||||
}
|
||||
else
|
||||
if(t[1] == 'p' && t[2] == 'o' && t[3] == 's' && t[4] == ';') {
|
||||
t += 5;
|
||||
out.Cat('\'');
|
||||
}
|
||||
else
|
||||
out.Cat('&');
|
||||
else
|
||||
if(t[0] == 'q' && t[1] == 'u' && t[2] == 'o' && t[3] == 't' && t[4] == ';') {
|
||||
t += 5;
|
||||
out.Cat('\"');
|
||||
}
|
||||
else
|
||||
out.Cat('&');
|
||||
term = t;
|
||||
out.Cat('&');
|
||||
}
|
||||
|
||||
inline static bool IsXmlNameChar(int c)
|
||||
|
|
@ -425,6 +407,11 @@ void XmlParser::Next()
|
|||
}
|
||||
}
|
||||
|
||||
void XmlParser::RegisterEntity(const String& id, const String& text)
|
||||
{
|
||||
entity.Add(id, text);
|
||||
}
|
||||
|
||||
bool XmlParser::IsEof()
|
||||
{
|
||||
return type == XML_EOF;
|
||||
|
|
@ -677,6 +664,11 @@ int XmlParser::GetColumn() const
|
|||
|
||||
XmlParser::XmlParser(const char *s)
|
||||
{
|
||||
RegisterEntity("lt", "<");
|
||||
RegisterEntity("gt", ">");
|
||||
RegisterEntity("amp", "&");
|
||||
RegisterEntity("apos", "\'");
|
||||
RegisterEntity("quot", "\"");
|
||||
relaxed = false;
|
||||
empty_tag = false;
|
||||
npreserve = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue