Minor XML fixes

git-svn-id: svn://ultimatepp.org/upp/trunk@903 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2009-02-24 19:39:43 +00:00
parent fbde91189f
commit 97646cb89a
2 changed files with 25 additions and 18 deletions

View file

@ -181,6 +181,23 @@ void XmlParser::SkipWhites()
}
}
void XmlParser::ReadAttr(StringBuffer& attrval, int c)
{
term++;
while(*term && *term != c)
if(*term == '&')
Ent(attrval);
else {
const char *e = term;
while(*++e && *e != '&' && *e != c)
;
attrval.Cat(term, (int)(e - term));
term = e;
}
if(*term == c)
term++;
}
void XmlParser::Next()
{
nattr.Clear();
@ -293,23 +310,13 @@ void XmlParser::Next()
term++;
SkipWhites();
StringBuffer attrval;
if(*term == '\"') {
term++;
while(*term && *term != '\"')
if(*term == '&')
Ent(attrval);
else {
const char *e = term;
while(*++e && *e != '&' && *e != '\"')
;
attrval.Cat(term, (int)(e - term));
term = e;
}
if(*term == '\"')
term++;
}
else {
while((byte)*term > ' ' && *term != '>')
if(*term == '\"')
ReadAttr(attrval, '\"');
else
if(*term == '\'')
ReadAttr(attrval, '\'');
else
while((byte)*term > ' ' && *term != '>' && *term != '/')
if(*term == '&')
Ent(attrval);
else {
@ -319,7 +326,6 @@ void XmlParser::Next()
attrval.Cat(term,(int) (e - term));
term = e;
}
}
if(attr == "xml:space" && attrval.GetLength() == 8 && !memcmp(~attrval, "preserve", 8))
npreserve = true;
String aval = FromUtf8(~attrval, attrval.GetLength()).ToString();

View file

@ -60,6 +60,7 @@ class XmlParser {
void Ent(StringBuffer& out);
void Next();
void ReadAttr(StringBuffer& b, int c);
public:
void SkipWhites();