//
// sheet2html.cs: Simple tool to convert dia sheets to HTML fragments
//
// Author:
// Steffen Macke (sdteffen@sdteffen.de)
//
// Copyright (C) 2007 Steffen Macke (http://dia-installer.de)
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
//
using System;
using System.Xml.XPath;
using System.Xml;
public class Sheet2Html {
public static void Main(string[] args) {
if(args.Length != 1) {
Console.Error.WriteLine("USAGE: sheet2html sheetname");
return;
}
XPathNavigator nav =
new XPathDocument ("sheets/"+args[0]+".sheet").CreateNavigator ();
nav.MoveToFirstNamespace();
XPathNodeIterator links = nav.Select ("/sheet/contents/object");
while (links.MoveNext ()) {
string sDescription = links.Current.Value;
string sName = links.Current.GetAttribute("name", "");
Console.WriteLine("");
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo("shapes/"+args[0]);
foreach(System.IO.FileInfo f in dir.GetFiles("*.shape"))
{
XmlDocument shape = new XmlDocument();
shape.Load(f.FullName);
XmlNamespaceManager nsmgr = new XmlNamespaceManager(shape.NameTable);
nsmgr.AddNamespace("", "http://www.daa.com.au/~james/dia-shape-nsi");
XmlNodeList nodeList;
XmlElement root = shape.DocumentElement;
nodeList = root.SelectNodes("/shape/name/text() ['"+sName+"i']");
if(root.FirstChild.FirstChild.Value == sName)
{
Console.WriteLine("
 | "+sDescription+" |
");
}
}
}
}
}