Beispiel #1
0
	private static void Main2() {
		if (opts.dumptemplate) {
			DumpTemplate();
			return;
		}
		
		if (opts.source == null || opts.source == "" || opts.dest == null || opts.dest == "")
			throw new ApplicationException("The source and dest options must be specified.");
		
		Directory.CreateDirectory(opts.dest);
		
		// Load the stylesheets, overview.xml, and resolver
		
		XslTransform overviewxsl = LoadTransform("overview.xsl");
		XslTransform stylesheet = LoadTransform("stylesheet.xsl");
		XslTransform template;
		if (opts.template == null) {
			template = LoadTransform("defaulttemplate.xsl");
		} else {
			try {
				XmlDocument templatexsl = new XmlDocument();
				templatexsl.Load(opts.template);
				template = new XslTransform();
				template.Load(templatexsl);
			} catch (Exception e) {
				throw new ApplicationException("There was an error loading " + opts.template, e);
			}
		}
		
		XmlDocument overview = new XmlDocument();
		overview.Load(opts.source + "/index.xml");

		ArrayList extensions = GetExtensionMethods (overview);
		
		// Create the master page
		XsltArgumentList overviewargs = new XsltArgumentList();
		overviewargs.AddParam("ext", "", opts.ext);
		overviewargs.AddParam("basepath", "", "./");
		Generate(overview, overviewxsl, overviewargs, opts.dest + "/index." + opts.ext, template);
		overviewargs.RemoveParam("basepath", "");
		overviewargs.AddParam("basepath", "", "../");
		
		// Create the namespace & type pages
		
		XsltArgumentList typeargs = new XsltArgumentList();
		typeargs.AddParam("ext", "", opts.ext);
		typeargs.AddParam("basepath", "", "../");
		
		foreach (XmlElement ns in overview.SelectNodes("Overview/Types/Namespace")) {
			string nsname = ns.GetAttribute("Name");

			if (opts.onlytype != null && !opts.onlytype.StartsWith(nsname + "."))
				continue;
				
			System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(opts.dest + "/" + nsname);
			if (!d.Exists) d.Create();
			
			// Create the NS page
			overviewargs.AddParam("namespace", "", nsname);
			Generate(overview, overviewxsl, overviewargs, opts.dest + "/" + nsname + "/index." + opts.ext, template);
			overviewargs.RemoveParam("namespace", "");
			
			foreach (XmlElement ty in ns.SelectNodes("Type")) {
				string typefilebase = ty.GetAttribute("Name");
				string typename = ty.GetAttribute("DisplayName");
				if (typename.Length == 0)
					typename = typefilebase;
				
				if (opts.onlytype != null && !(nsname + "." + typename).StartsWith(opts.onlytype))
					continue;

				string typefile = opts.source + "/" + nsname + "/" + typefilebase + ".xml";
				if (!File.Exists(typefile)) continue;

				XmlDocument typexml = new XmlDocument();
				typexml.Load(typefile);
				if (extensions != null) {
					DocLoader loader = CreateDocLoader (overview);
					XmlDocUtils.AddExtensionMethods (typexml, extensions, loader);
				}
				
				Console.WriteLine(nsname + "." + typename);
				
				Generate(typexml, stylesheet, typeargs, opts.dest + "/" + nsname + "/" + typefilebase + "." + opts.ext, template);
			}
		}
	}
Beispiel #2
0
        void ProcessDirectories(List <string> sourceDirectories)
        {
            if (sourceDirectories.Count == 0 || opts.dest == null || opts.dest == "")
            {
                throw new ApplicationException("The source and dest options must be specified.");
            }

            Directory.CreateDirectory(opts.dest);

            // Load the stylesheets, overview.xml, and resolver

            XslTransform overviewxsl = LoadTransform("overview.xsl", sourceDirectories);
            XslTransform stylesheet  = LoadTransform("stylesheet.xsl", sourceDirectories);
            XslTransform template;

            if (opts.template == null)
            {
                template = LoadTransform("defaulttemplate.xsl", sourceDirectories);
            }
            else
            {
                try {
                    XmlDocument templatexsl = new XmlDocument();
                    templatexsl.Load(opts.template);
                    template = new XslTransform();
                    template.Load(templatexsl);
                } catch (Exception e) {
                    throw new ApplicationException("There was an error loading " + opts.template, e);
                }
            }

            XmlDocument overview = GetOverview(sourceDirectories);

            ArrayList extensions = GetExtensionMethods(overview);

            // Create the master page
            XsltArgumentList overviewargs = new XsltArgumentList();

            var regenIndex = ShouldRegenIndexes(opts, overview, sourceDirectories);

            if (regenIndex)
            {
                overviewargs.AddParam("ext", "", opts.ext);
                overviewargs.AddParam("basepath", "", "./");
                Generate(overview, overviewxsl, overviewargs, opts.dest + "/index." + opts.ext, template, sourceDirectories);
                overviewargs.RemoveParam("basepath", "");
            }
            overviewargs.AddParam("basepath", "", "../");
            overviewargs.AddParam("Index", "", overview.CreateNavigator());

            // Create the namespace & type pages

            XsltArgumentList typeargs = new XsltArgumentList();

            typeargs.AddParam("ext", "", opts.ext);
            typeargs.AddParam("basepath", "", "../");
            typeargs.AddParam("Index", "", overview.CreateNavigator());

            foreach (XmlElement ns in overview.SelectNodes("Overview/Types/Namespace"))
            {
                string nsname = ns.GetAttribute("Name");

                if (opts.onlytype != null && !opts.onlytype.StartsWith(nsname + "."))
                {
                    continue;
                }

                System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(opts.dest + "/" + nsname);
                if (!d.Exists)
                {
                    d.Create();
                }

                // Create the NS page
                string nsDest = opts.dest + "/" + nsname + "/index." + opts.ext;
                if (regenIndex)
                {
                    overviewargs.AddParam("namespace", "", nsname);
                    Generate(overview, overviewxsl, overviewargs, nsDest, template, sourceDirectories);
                    overviewargs.RemoveParam("namespace", "");
                }

                foreach (XmlElement ty in ns.SelectNodes("Type"))
                {
                    string typename, typefile, destfile;
                    GetTypePaths(opts, ty, out typename, out typefile, out destfile);

                    if (DestinationIsNewer(typefile, destfile))
                    {
                        // target already exists, and is newer.  why regenerate?
                        continue;
                    }

                    XmlDocument typexml = new XmlDocument();
                    typexml.Load(typefile);
                    PreserveMembersInVersions(typexml);
                    if (extensions != null)
                    {
                        DocLoader loader = CreateDocLoader(overview);
                        XmlDocUtils.AddExtensionMethods(typexml, extensions, loader);
                    }

                    Console.WriteLine(nsname + "." + typename);

                    Generate(typexml, stylesheet, typeargs, destfile, template, sourceDirectories);
                }
            }
        }
 public object Set(string name, string value)
 {
     xsltArgList.RemoveParam(name, NS);
     xsltArgList.AddParam(name, NS, value);
     return(string.Empty);
 }
Beispiel #4
0
 /// <summary>
 /// This method removes a parameter from the inherent parameter list.
 /// </summary>
 /// <param name="name">The name of the parameter</param>
 public object RemoveParam(string name)
 {
     return(_ArgumentList.RemoveParam(name, string.Empty));
 }
Beispiel #5
0
    private static void Main2()
    {
        if (opts.dumptemplate)
        {
            DumpTemplate();
            return;
        }

        if (opts.source == null || opts.source == "" || opts.dest == null || opts.dest == "")
        {
            throw new ApplicationException("The source and dest options must be specified.");
        }

        Directory.CreateDirectory(opts.dest);

        // Load the stylesheets, overview.xml, and resolver

        XslTransform overviewxsl = LoadTransform("overview.xsl");
        XslTransform stylesheet  = LoadTransform("stylesheet.xsl");
        XslTransform template;

        if (opts.template == null)
        {
            template = LoadTransform("defaulttemplate.xsl");
        }
        else
        {
            try {
                XmlDocument templatexsl = new XmlDocument();
                templatexsl.Load(opts.template);
                template = new XslTransform();
                template.Load(templatexsl);
            } catch (Exception e) {
                throw new ApplicationException("There was an error loading " + opts.template, e);
            }
        }

        XmlDocument overview = new XmlDocument();

        overview.Load(opts.source + "/index.xml");

        ArrayList extensions = GetExtensionMethods(overview);

        // Create the master page
        XsltArgumentList overviewargs = new XsltArgumentList();

        overviewargs.AddParam("ext", "", opts.ext);
        overviewargs.AddParam("basepath", "", "./");
        Generate(overview, overviewxsl, overviewargs, opts.dest + "/index." + opts.ext, template);
        overviewargs.RemoveParam("basepath", "");
        overviewargs.AddParam("basepath", "", "../");

        // Create the namespace & type pages

        XsltArgumentList typeargs = new XsltArgumentList();

        typeargs.AddParam("ext", "", opts.ext);
        typeargs.AddParam("basepath", "", "../");

        foreach (XmlElement ns in overview.SelectNodes("Overview/Types/Namespace"))
        {
            string nsname = ns.GetAttribute("Name");

            if (opts.onlytype != null && !opts.onlytype.StartsWith(nsname + "."))
            {
                continue;
            }

            System.IO.DirectoryInfo d = new System.IO.DirectoryInfo(opts.dest + "/" + nsname);
            if (!d.Exists)
            {
                d.Create();
            }

            // Create the NS page
            overviewargs.AddParam("namespace", "", nsname);
            Generate(overview, overviewxsl, overviewargs, opts.dest + "/" + nsname + "/index." + opts.ext, template);
            overviewargs.RemoveParam("namespace", "");

            foreach (XmlElement ty in ns.SelectNodes("Type"))
            {
                string typefilebase = ty.GetAttribute("Name");
                string typename     = ty.GetAttribute("DisplayName");
                if (typename.Length == 0)
                {
                    typename = typefilebase;
                }

                if (opts.onlytype != null && !(nsname + "." + typename).StartsWith(opts.onlytype))
                {
                    continue;
                }

                string typefile = opts.source + "/" + nsname + "/" + typefilebase + ".xml";
                if (!File.Exists(typefile))
                {
                    continue;
                }

                XmlDocument typexml = new XmlDocument();
                typexml.Load(typefile);
                if (extensions != null)
                {
                    DocLoader loader = CreateDocLoader(overview);
                    XmlDocUtils.AddExtensionMethods(typexml, extensions, loader);
                }

                Console.WriteLine(nsname + "." + typename);

                Generate(typexml, stylesheet, typeargs, opts.dest + "/" + nsname + "/" + typefilebase + "." + opts.ext, template);
            }
        }
    }