5 using System.Xml.XPath;
6 using System.Collections.Generic;
8 namespace Monodoc.Generators.Html
10 public class Ecmaspec2Html : IHtmlExporter
12 static string css_ecmaspec;
13 static XslTransform ecma_transform;
14 static XsltArgumentList args = new XsltArgumentList();
16 public string CssCode {
18 if (css_ecmaspec != null)
20 System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
21 Stream str_css = assembly.GetManifestResourceStream ("ecmaspec.css");
22 css_ecmaspec = (new StreamReader (str_css)).ReadToEnd ();
29 public string Colorize (string code, string lang)
31 return Mono.Utilities.Colorizer.Colorize (code, lang);
35 public string Export (Stream stream, Dictionary<string, string> extraArgs)
37 return Htmlize (new XPathDocument (stream));
40 public string Export (string input, Dictionary<string, string> extraArgs)
42 return Htmlize (new XPathDocument (new StringReader (input)));
45 static string Htmlize (XPathDocument ecma_xml)
47 if (ecma_transform == null){
48 ecma_transform = new XslTransform ();
49 System.Reflection.Assembly assembly = System.Reflection.Assembly.GetAssembly (typeof (Ecmaspec2Html));
51 stream = assembly.GetManifestResourceStream ("ecmaspec-html-css.xsl");
53 XmlReader xml_reader = new XmlTextReader (stream);
54 ecma_transform.Load (xml_reader, null, null);
55 args.AddExtensionObject ("monodoc:///extensions", new ExtObj ());
58 if (ecma_xml == null) return "";
60 StringWriter output = new StringWriter ();
61 ecma_transform.Transform (ecma_xml, args, output, null);
63 return output.ToString ();