Fix parsing

This commit is contained in:
Vladimir Panteleev 2010-06-16 00:55:24 +03:00
parent e306af923c
commit 6f61ebd302
2 changed files with 22 additions and 5 deletions

View File

@ -140,6 +140,23 @@ class XmlNode
}
}
string text()
{
switch(type)
{
case XmlNodeType.Text:
return convertEntities(tag);
case XmlNodeType.Node:
case XmlNodeType.Root:
string childrenText;
foreach(child;children)
childrenText ~= child.text();
return childrenText;
default:
return null;
}
}
final XmlNode findChild(string tag)
{
foreach(child;children)
@ -243,7 +260,7 @@ void skipWhitespace(Stream s)
bool isWord(char c)
{
return c=='-' || c=='_' || isalnum(c);
return c=='-' || c=='_' || c==':' || isalnum(c);
}
string readWord(Stream s)

View File

@ -26,11 +26,11 @@ int main(string[] args)
foreach (child; xml[0]["page"])
if (child.tag=="revision")
{
string summary = child["comment"].toString;
string text = child["text"].toString;
string summary = child["comment"] ? child["comment"].text : null;
string text = child["text"].text;
data ~=
"commit master\n" ~
"committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].toString : child["contributor"]["ip"].toString) ~ "> now\n" ~
"committer <" ~ (child["contributor"]["username"] ? child["contributor"]["username"].text : child["contributor"]["ip"].text) ~ "> now\n" ~
"data " ~ .toString(summary.length) ~ "\n" ~
summary ~ "\n" ~
"M 644 inline " ~ name ~ ".txt\n" ~
@ -38,6 +38,6 @@ int main(string[] args)
text ~ "\n" ~
"\n";
}
write("fast-import-data", data);
return 0;
}