X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=web%2Fweb%2Frender-team-page.cs;h=39ad660855e551cf0cc9bf90dc630609214752cb;hb=7d1d281daa5ff4e1661ac9fe1e3b30035fcf2542;hp=9ea9095eba24f9ce133535748278de019a75a24d;hpb=1f16adccf74261fe5ef394d54804961343543eb9;p=mono.git diff --git a/web/web/render-team-page.cs b/web/web/render-team-page.cs index 9ea9095eba2..39ad660855e 100644 --- a/web/web/render-team-page.cs +++ b/web/web/render-team-page.cs @@ -15,6 +15,7 @@ using System.Xml; class Write { static Contributor [] list; + static public XmlNamespaceManager nsmgr; static void Main (string [] args) { @@ -28,7 +29,9 @@ class Write { XmlDocument document = new XmlDocument (); document.Load (input); - XmlNodeList contributors = document.SelectNodes ("/contributors/contributor"); + nsmgr = new XmlNamespaceManager (document.NameTable); + nsmgr.AddNamespace ("t", "http://go-mono.org/team.xsd"); + XmlNodeList contributors = document.SelectNodes ("/t:contributors/t:contributor", nsmgr); list = new Contributor [contributors.Count]; Page p = new Page (); @@ -61,7 +64,7 @@ public class ContributorComparer : IComparer { public int Compare (object x, object y) { - return String.Compare (x as string , y as string); + return String.Compare (x.ToString (), y.ToString ()); } } @@ -81,11 +84,11 @@ class Contributor { { name = GetName (node); - image = GetField (node, "image"); - email = GetField (node, "e-mail"); - location = GetField (node, "location"); - organization = GetField (node, "organization"); - description = GetField (node, "description"); + image = GetImage (node); + email = GetField (node, "t:e-mail"); + location = GetField (node, "t:location"); + organization = GetField (node, "t:organization"); + description = GetField (node, "t:description"); tasks = GetTasks (node); this.document = document; @@ -96,9 +99,20 @@ class Contributor { return name.ToString (); } + public static string GetImage (XmlNode node) + { + string result = GetField (node, "t:image"); + + if (result == String.Empty) + return "none.png"; + + else + return result; + } + public static string GetField (XmlNode node, string selector) { - XmlNode result = node.SelectSingleNode (selector); + XmlNode result = node.SelectSingleNode (selector, Write.nsmgr); if (result == null) return String.Empty; @@ -108,15 +122,15 @@ class Contributor { public static Name GetName (XmlNode node) { - string first_name = GetField (node, "name/first-name"); - string last_name = GetField (node, "name/last-name"); + string first_name = GetField (node, "t:name/t:first-name"); + string last_name = GetField (node, "t:name/t:last-name"); return new Name (first_name, last_name); } public static string [] GetTasks (XmlNode node) { - XmlNodeList nodes = node.SelectNodes ("tasks/task"); + XmlNodeList nodes = node.SelectNodes ("t:tasks/t:task", Write.nsmgr); string [] result = new string [nodes.Count]; @@ -132,71 +146,74 @@ class Contributor { public XmlElement RenderHtml () { - XmlElement root = document.CreateElement ("TD"); - XmlElement table = document.CreateElement ("TABLE"); - table.SetAttribute ("width", "100%"); - XmlElement tr = document.CreateElement ("TR"); - XmlElement td = document.CreateElement ("TD"); + XmlElement root = document.CreateElement ("td"); + XmlElement table = document.CreateElement ("table"); + table.SetAttribute ("cellPadding", "0"); + table.SetAttribute ("border", "0"); + XmlElement tr = document.CreateElement ("tr"); + XmlElement td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#c3cda7"); td.SetAttribute ("valign", "top"); + td.SetAttribute ("width", "1%"); tr.AppendChild (td); table.AppendChild (tr); root.AppendChild (table); - XmlElement img = document.CreateElement ("IMG"); + XmlElement img = document.CreateElement ("img"); img.SetAttribute ("align", "top"); img.SetAttribute ("border", "0"); img.SetAttribute ("height", "48"); img.SetAttribute ("width", "48"); - img.SetAttribute ("src", image); + img.SetAttribute ("src", "team/" + image); td.AppendChild (img); td = document.CreateElement ("TD"); td.SetAttribute ("bgcolor", "#c3cda7"); td.SetAttribute ("valign", "bottom"); + td.SetAttribute ("width", "100%"); tr.AppendChild (td); td.AppendChild (name.ToXml (document)); - td.AppendChild (document.CreateElement ("BR")); + td.AppendChild (document.CreateElement ("br")); td.AppendChild (RenderEmail ()); - tr = document.CreateElement ("TR"); + tr = document.CreateElement ("tr"); table.AppendChild (tr); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); td.AppendChild (RenderLabel ("Location: ")); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); td.AppendChild (document.CreateTextNode (location)); - tr = document.CreateElement ("TR"); + tr = document.CreateElement ("tr"); table.AppendChild (tr); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); td.AppendChild (RenderLabel ("Description: ")); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); td.AppendChild (document.CreateTextNode (description)); - tr = document.CreateElement ("TR"); + tr = document.CreateElement ("tr"); table.AppendChild (tr); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); td.AppendChild (RenderLabel ("Tasks: ")); - td = document.CreateElement ("TD"); + td = document.CreateElement ("td"); td.SetAttribute ("bgcolor", "#f5f8e4"); td.SetAttribute ("valign", "top"); tr.AppendChild (td); @@ -208,11 +225,11 @@ class Contributor { public XmlNode RenderTasks () { - XmlElement element = document.CreateElement ("OL"); + XmlElement element = document.CreateElement ("ol"); element.SetAttribute ("type", "I"); foreach (string task in tasks) { - XmlElement li = document.CreateElement ("LI"); + XmlElement li = document.CreateElement ("li"); li.AppendChild (document.CreateTextNode (task)); element.AppendChild (li); } @@ -222,9 +239,9 @@ class Contributor { public XmlNode RenderEmail () { - XmlElement a = document.CreateElement ("A"); + XmlElement a = document.CreateElement ("a"); a.SetAttribute ("href", "mailto:" + email); - XmlElement font = document.CreateElement ("FONT"); + XmlElement font = document.CreateElement ("font"); font.SetAttribute ("size", "3"); XmlText t = document.CreateTextNode (email); a.AppendChild (font); @@ -236,7 +253,7 @@ class Contributor { public XmlNode RenderLabel (string label) { string text = String.Format ("{0}: ", label); - XmlElement element = document.CreateElement ("B"); + XmlElement element = document.CreateElement ("b"); XmlText t = document.CreateTextNode (label ); element.AppendChild (t); @@ -252,19 +269,11 @@ class Page { public Page () { document = new XmlDocument (); - XmlElement html = document.CreateElement ("HTML"); - document.AppendChild (html); - - XmlElement head = document.CreateElement ("HEAD"); - html.AppendChild (head); - - XmlElement body = document.CreateElement ("BODY"); - html.AppendChild (body); - XmlElement table = document.CreateElement ("TABLE"); - body.AppendChild (table); + XmlElement table = document.CreateElement ("table"); + document.AppendChild (table); - tbody = document.CreateElement ("TBODY"); + tbody = document.CreateElement ("tbody"); table.AppendChild (tbody); } @@ -277,12 +286,12 @@ class Page { if (left == null && right == null) return; - XmlElement tr = document.CreateElement ("TR"); + XmlElement tr = document.CreateElement ("tr"); tbody.AppendChild (tr); tr.AppendChild (left); if (right == null) - tr.AppendChild (document.CreateElement ("TD")); + tr.AppendChild (document.CreateElement ("td")); else { tr.SetAttribute ("valign", "top"); tr.AppendChild (right); @@ -331,7 +340,7 @@ class Name { public XmlNode ToXml (XmlDocument document) { - XmlElement element = document.CreateElement ("FONT"); + XmlElement element = document.CreateElement ("font"); element.SetAttribute ("size", "3"); XmlElement b = document.CreateElement ("B"); XmlText t = document.CreateTextNode (ToString ());