[Mono-docs-list] Handbook Xhtmlified

Johannes Roith johannes@jroith.de
Thu, 1 May 2003 15:18:11 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_0001_01C30FF4.E1725830
Content-Type: text/plain;
	charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hello!

I have Xhtmlified the Handbook. There are still some problems, but I
will clean those up.
As proof of miguels link changing concept, the attached sample reads the
Toc, displays the title, url and prints a link list for the page.

Maybe this is useful for the monodoc provider.

Johannes

------=_NextPart_000_0001_01C30FF4.E1725830
Content-Type: application/octet-stream;
	name="parserandreader.cs"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
	filename="parserandreader.cs"

// Simple Parser for the Handbook TOC format
// Copyright 2003 by Johannes Roith

using System;
using System.Xml;
using System.IO;

public class SimpleHandbookTOCParser
{

public static XmlDocument newdoc;

public static string spaces =3D "";

  public static void Main()
  {

	XmlDocument doc =3D new XmlDocument();
	doc.Load("Documentation.xml");

	XmlNodeList nodeList =3D doc.GetElementsByTagName("body");
	XmlNodeList bodylist =3D nodeList[0].ChildNodes[1].ChildNodes;

	ParseUl(bodylist[1].ChildNodes);
   }


   public static void ParseUl(XmlNodeList items)
   {


	for (int i =3D 0;i < items.Count;i++)
	{   =20


		if (items[i].LocalName =3D=3D "li")
		{

			string[] attribs =3D ParseLi(items[i]);

			if (items.Count > i+1 && items[i+1].LocalName =3D=3D "ul")
			{
				Console.WriteLine(spaces + "+" + attribs[0] + ": " + attribs[1]);
			}
			else {
				Console.WriteLine( spaces + attribs[0] + ": " + attribs[1]);
			}
=09
			if(File.Exists(Environment.CurrentDirectory + "\\" + attribs[1])) {

				try {
					newdoc =3D new XmlDocument();
					newdoc.Load(Environment.CurrentDirectory + "\\" + attribs[1]);
	=09
					XmlNodeList nodeList =3D newdoc.GetElementsByTagName("a");
					foreach(XmlNode node in nodeList) {
=09
						try {
							Console.WriteLine(spaces + "   " + =
node.Attributes.GetNamedItem("href").Value);
						}
						catch
						{
						}
					}
=09
				}

				catch
				{
					Console.WriteLine(spaces + "-- PARSE ERROR --");
				}

			}

			}

		if (items[i].LocalName =3D=3D "ul")
		{
			spaces +=3D "      ";
			ParseUl(items[i].ChildNodes);
			spaces =3D spaces.Substring(6);
		}

	}

=09
   }


   public static string[] ParseLi(XmlNode me)
   {
	string[] values =3D {null, null};

		foreach (XmlNode param in me.ChildNodes[0].ChildNodes)
		{   =20
			if (param.Attributes.GetNamedItem("name").Value =3D=3D "Name")
					values[0] =3D  param.Attributes.GetNamedItem("value").Value;	=09

			if (param.Attributes.GetNamedItem("name").Value =3D=3D "Local")
					values[1] =3D  param.Attributes.GetNamedItem("value").Value;
		}

	return values;
=09
   }
}

------=_NextPart_000_0001_01C30FF4.E1725830--