private void WriteFoafPerson(XmlWriter writer, FoafPerson person)
{
writer.WriteStartElement("foaf", "Person", null);
// if (person.ID != "")
// {
// writer.WriteAttributeString("rdf", "ID", null, person.ID);
// }
writer.WriteElementString("foaf", "name", null, person.Name);
if (person.Title != string.Empty)
{
writer.WriteElementString("foaf", "title", null, person.Title);
}
if (person.Firstname != string.Empty)
{
writer.WriteElementString("foaf", "givenname", null, person.Firstname);
}
if (person.Lastname != string.Empty)
{
writer.WriteElementString("foaf", "family_name", null, person.Lastname);
}
if (!string.IsNullOrEmpty(person.Email))
{
writer.WriteElementString("foaf", "mbox_sha1sum", null, CalculateSha1(person.Email, Encoding.UTF8));
}
if (!string.IsNullOrEmpty(person.Homepage))
{
writer.WriteStartElement("foaf", "homepage", null);
writer.WriteAttributeString("rdf", "resource", null, person.Homepage);
writer.WriteEndElement();
}
if (!string.IsNullOrEmpty(person.Blog))
{
writer.WriteStartElement("foaf", "weblog", null);
writer.WriteAttributeString("rdf", "resource", null, person.Blog);
writer.WriteEndElement();
}
if (person.Rdf != string.Empty && person.Rdf != HttpContext.Current.Request.Url.ToString())
{
writer.WriteStartElement("rdfs", "seeAlso", null);
writer.WriteAttributeString("rdf", "resource", null, person.Rdf);
writer.WriteEndElement();
}
if (!string.IsNullOrEmpty(person.Birthday))
{
writer.WriteElementString("foaf", "birthday", null, person.Birthday);
}
if (!string.IsNullOrEmpty(person.PhotoUrl))
{
writer.WriteStartElement("foaf", "depiction", null);
writer.WriteAttributeString("rdf", "resource", null, person.PhotoUrl);
writer.WriteEndElement();
}
if (!string.IsNullOrEmpty(person.Phone))
{
writer.WriteElementString("foaf", "phone", null, person.Phone);
}
if (person.Friends != null && person.Friends.Count > 0)
{
foreach (var friend in person.Friends)
{
writer.WriteStartElement("foaf", "knows", null);
this.WriteFoafPerson(writer, friend);
writer.WriteEndElement(); // foaf:knows
}
}
writer.WriteEndElement(); // foaf:Person
}