diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2005-11-08 15:02:58 +0300 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2005-11-08 15:02:58 +0300 |
commit | dbefbf7c562ccd69dd4a76bbbdba45fd73d4869f (patch) | |
tree | ba2735e302e1441fa70c6aeee73adbf8be31d072 /web | |
parent | 05645ff090aec2d98dd888dc6dc0036822705176 (diff) |
it is largely XHTMLified.
svn path=/trunk/mono/; revision=52698
Diffstat (limited to 'web')
-rw-r--r-- | web/web/XhtmlWriter.cs | 254 | ||||
-rw-r--r-- | web/web/htmlify | 6 | ||||
-rw-r--r-- | web/web/makefile | 2 | ||||
-rwxr-xr-x | web/web/process.pl | 10 | ||||
-rw-r--r-- | web/web/template.html.in | 33 | ||||
-rw-r--r-- | web/web/transform.cs | 6 |
6 files changed, 284 insertions, 27 deletions
diff --git a/web/web/XhtmlWriter.cs b/web/web/XhtmlWriter.cs new file mode 100644 index 00000000000..f7db3ead8a8 --- /dev/null +++ b/web/web/XhtmlWriter.cs @@ -0,0 +1,254 @@ +// +// XhtmlWriter.cs +// +// Author: +// Atsushi Enomoto <atsushi@ximian.com> +// +// Copyright (C) 2005 Novell, Inc. http://www.novell.com +// +using System; +using System.Globalization; +using System.Collections; +using System.Xml; + +namespace Mono.Xml.Ext +{ + public class XhtmlWriter : DefaultXmlWriter + { + XmlWriter writer; + Stack localNames; + Stack namespaces; + + public XhtmlWriter (XmlWriter writer) : base (writer) + { + this.writer = writer; + localNames = new Stack (); + namespaces = new Stack (); + } + + public override void WriteStartElement (string prefix, string localName, string ns) + { + localNames.Push (localName); + namespaces.Push (ns); + writer.WriteStartElement (prefix, localName, ns); + } + + public override void WriteEndElement () + { + WriteWiseEndElement (false); + } + + public override void WriteFullEndElement () + { + WriteWiseEndElement (true); + } + + void WriteWiseEndElement (bool full) + { + string localName = localNames.Pop () as string; + string ns = namespaces.Pop () as string; + if (ns == "http://www.w3.org/1999/xhtml") { + switch (localName.ToLower (CultureInfo.InvariantCulture)) { + case "area": + case "base": + case "basefont": + case "br": + case "col": + case "frame": + case "hr": + case "img": + case "input": + case "isindex": + case "link": + case "meta": + case "param": + full = false; + break; + default: + full = true; + break; + } + } + if (full) + writer.WriteFullEndElement (); + else + writer.WriteEndElement (); + } + } + + public class DefaultXmlWriter : XmlWriter + { + XmlWriter writer; + + public DefaultXmlWriter (XmlWriter writer) + { + this.writer = writer; + } + + public override void Close () + { + writer.Close (); + } + + public override void Flush () + { + writer.Flush (); + } + + public override string LookupPrefix (string ns) + { + return writer.LookupPrefix (ns); + } + + public override void WriteBase64 (byte [] buffer, int index, int count) + { + writer.WriteBase64 (buffer, index, count); + } + + public override void WriteBinHex (byte [] buffer, int index, int count) + { + writer.WriteBinHex (buffer, index, count); + } + + public override void WriteCData (string text) + { + writer.WriteCData (text); + } + + public override void WriteCharEntity (char ch) + { + writer.WriteCharEntity (ch); + } + + public override void WriteChars (char [] buffer, int index, int count) + { + writer.WriteChars (buffer, index, count); + } + + public override void WriteComment (string text) + { + writer.WriteComment (text); + } + + public override void WriteDocType (string name, string pubid, string sysid, string subset) + { + writer.WriteDocType (name, pubid, sysid, subset); + } + + public override void WriteEndAttribute () + { + writer.WriteEndAttribute (); + } + + public override void WriteEndDocument () + { + writer.WriteEndDocument (); + } + + public override void WriteEndElement () + { + writer.WriteEndElement (); + } + + public override void WriteEntityRef (string name) + { + writer.WriteEntityRef (name); + } + + public override void WriteFullEndElement () + { + writer.WriteFullEndElement (); + } + + public override void WriteName (string name) + { + writer.WriteName (name); + } + + public override void WriteNmToken (string name) + { + writer.WriteNmToken (name); + } + + public override void WriteNode (XmlReader reader, bool defattr) + { + writer.WriteNode (reader, defattr); + } + + public override void WriteProcessingInstruction (string name, string text) + { + writer.WriteProcessingInstruction (name, text); + } + + public override void WriteQualifiedName (string localName, string ns) + { + writer.WriteQualifiedName (localName, ns); + } + + public override void WriteRaw (string data) + { + writer.WriteRaw (data); + } + + public override void WriteRaw (char [] buffer, int index, int count) + { + writer.WriteRaw (buffer, index, count); + } + + public override void WriteStartAttribute (string prefix, string localName, string ns) + { + writer.WriteStartAttribute (prefix, localName, ns); + } + + public override void WriteStartDocument (bool standalone) + { + writer.WriteStartDocument (standalone); + } + + public override void WriteStartDocument () + { + writer.WriteStartDocument (); + } + + public override void WriteStartElement (string prefix, string localName, string ns) + { + writer.WriteStartElement (prefix, localName, ns); + } + + public override void WriteString (string text) + { + writer.WriteString (text); + } + + public override void WriteSurrogateCharEntity (char lowChar, char highChar) + { + writer.WriteSurrogateCharEntity (lowChar, highChar); + } + + public override void WriteWhitespace (string ws) + { + writer.WriteWhitespace (ws); + } + + public override WriteState WriteState { + get { + return writer.WriteState; + } + } + + public override string XmlLang { + get { + return writer.XmlLang; + } + } + + public override XmlSpace XmlSpace { + get { + return writer.XmlSpace; + } + } + + } +} + + diff --git a/web/web/htmlify b/web/web/htmlify index f0473ba56c1..cd347cad09f 100644 --- a/web/web/htmlify +++ b/web/web/htmlify @@ -2,7 +2,7 @@ $q = 1; while (<>){ - chop; + chomp; if (/^\* (.*)$/){ print "<h1>$1</h1>\n"; } elsif (/^\*\* (.*)$/) { @@ -12,9 +12,9 @@ while (<>){ } elsif (/^\*\*\*\* (.*)$/) { print "<h4>$1</h4>\n"; } elsif (/^$/) { - print "<p>\n"; + print "<p>$1</p>\n"; } elsif (/^\t\t\* (.*)$/) { - print "<li>$1\n"; + print "<li>$1</li>\n"; } elsif (/^\@item (.*)$/){ $name = $link = $1; $link =~ s/ //g; diff --git a/web/web/makefile b/web/web/makefile index 26eac6fb25f..c2928dfe45e 100644 --- a/web/web/makefile +++ b/web/web/makefile @@ -163,7 +163,7 @@ push2: $(OBJECTS): $(patsubst deploy/%.html,src/%.src, $(OBJECTS)) transform.exe: transform.cs - $(CSC) transform.cs + $(CSC) transform.cs XhtmlWriter.cs .PRECIOUS: src/%.src diff --git a/web/web/process.pl b/web/web/process.pl index 48766f8f0b8..c0321afe2ef 100755 --- a/web/web/process.pl +++ b/web/web/process.pl @@ -19,14 +19,14 @@ my $menu = ""; open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; while (<COMMANDS>) { - chop; + chomp; my @command = split /,/; if ($command[0] != -1) { $menu .= "\t\t"; $menu .= "<tr><td valign=\"top\" class=\"navi" . $command[0]; $menu .= "\"><a class=\"navi" . $command[0]; $menu .= "\""; - $menu .= " HREF=\"$command[2]\">$command[1]</A></td></tr>\n\n"; + $menu .= " HREF=\"$command[2]\">$command[1]</a></td></tr>\n\n"; } } close COMMANDS; @@ -39,7 +39,7 @@ close TEMPLATE; open COMMANDS, $ARGV[0] || die "Can not open $ARGV[0]"; while (<COMMANDS>) { - chop; + chomp; my @command = split /,/; if ($command[2] =~ /^http:/){ @@ -72,13 +72,13 @@ while (<COMMANDS>) { $temp =~ s/#CONTENT#/$content/; $temp =~ s/#MENU#/$menu/; if ($css) { - $temp =~ s/#CSS#/<LINK rel="stylesheet" type="text\/css" href="$css">/; + $temp =~ s/#CSS#/<link rel="stylesheet" type="text\/css" href="$css" \/>/; } else { $temp =~ s/#CSS#//; } if ($script) { - $temp =~ s/#SCRIPT#/<SCRIPT src="$script"><\/SCRIPT>/; + $temp =~ s/#SCRIPT#/<script src="$script"><\/script>/; } else { $temp =~ s/#SCRIPT#//; } diff --git a/web/web/template.html.in b/web/web/template.html.in index 169ff8b7ce9..d9d9401794e 100644 --- a/web/web/template.html.in +++ b/web/web/template.html.in @@ -2,7 +2,7 @@ <html> <head> <title>#TITLE#</title> -<link rel="icon" href="MonoIcon.png" type="image/png"> +<link rel="icon" href="MonoIcon.png" type="image/png" /> <!-- background-image: url("images/bgsquares.gif"); --> <style type="text/css"> <!-- @@ -55,14 +55,14 @@ <table cellpadding="0" cellspacing="0" border="0" width="100%"> <tr> - <td><img src="images/pixel.gif" alt=""></td><!-- left border + <td><img src="images/pixel.gif" alt="" /></td><!-- left border --> <td colspan="4"> <table> <tr> <td> <a href="http://www.go-mono.com"><img - src="images/mono-new.gif" alt="mono-logo" border="0"></a> + src="images/mono-new.gif" alt="mono-logo" border="0" /></a> </td> <td> <a class="topmenu" href="download.html">Downloads</a> | @@ -75,25 +75,25 @@ </tr> </table> </td> - <td><img src="images/pixel.gif" alt=""></td><!-- right border + <td><img src="images/pixel.gif" alt="" /></td><!-- right border --> </tr> <tr> - <td><img src="images/pixel.gif" width="1" height="1" alt=""></td> + <td><img src="images/pixel.gif" width="1" height="1" alt="" /></td> <td colspan="3" bgcolor="black"><img src="images/pixel.gif" - height="2" alt=""></td> - <td bgcolor="black"><img src="images/pixel.gif" width="1" alt=""></td> - <td><img src="images/pixel.gif" alt=""></td> + height="2" alt="" /></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1" alt="" /></td> + <td><img src="images/pixel.gif" alt="" /></td> </tr> <tr> - <td width="100"><img src="images/pixel.gif" alt=""></td> + <td width="100"><img src="images/pixel.gif" alt="" /></td> <td valign="top"> <table cellpadding="2" valign="top" cellspacing="0" border="0"> #MENU# </table> </td> <td bgcolor="black" width="1"><img src="images/pixel.gif" - width="1" alt=""></td> + width="1" alt="" /></td> <td bgcolor="white" align="left" width="80%" valign="top"> <table cellpadding="16"> <tr><td> @@ -101,16 +101,16 @@ </td></tr> </table> </td> - <td bgcolor="black"><img src="images/pixel.gif" width="1" alt=""></td> - <td width="100"><img src="images/pixel.gif" alt=""></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1" alt="" /></td> + <td width="100"><img src="images/pixel.gif" alt="" /></td> </tr> <tr> <td colspan="2"> - <img src="images/pixel.gif" alt=""></td> + <img src="images/pixel.gif" alt="" /></td> <td colspan="2" bgcolor="black"><img src="images/pixel.gif" - height="1" alt=""></td> - <td bgcolor="black"><img src="images/pixel.gif" width="1" alt=""></td> - <td><img src="images/pixel.gif" alt=""></td> + height="1" alt="" /></td> + <td bgcolor="black"><img src="images/pixel.gif" width="1" alt="" /></td> + <td><img src="images/pixel.gif" alt="" /></td> </tr> <tr> @@ -120,7 +120,6 @@ </td> <td colspan="2"></td> </tr> - </tr> </table> </body> diff --git a/web/web/transform.cs b/web/web/transform.cs index af6424f90c3..a255a6a72c9 100644 --- a/web/web/transform.cs +++ b/web/web/transform.cs @@ -14,7 +14,11 @@ namespace Transform XslTransform xsl = new XslTransform (); xsl.Load (rgstrArgs [1]); - xsl.Transform (xml, null, Console.Out); + XmlTextWriter xtw = new XmlTextWriter (Console.Out); + xtw.Formatting = Formatting.Indented; + XmlWriter w = new Mono.Xml.Ext.XhtmlWriter (xtw); + xsl.Transform (xml, null, w); + w.Close (); } } } |