Пример #1
0
 private void cmdSelectXSD_Click(object sender, EventArgs e)
 {
     opf.Filter           = "XSD files|*.xsd|All files|*.*";
     opf.Title            = "XSD";
     opf.InitialDirectory = Properties.Settings.Default.XSDFolder;
     opf.CheckFileExists  = true;
     opf.FileName         = "";
     if (opf.ShowDialog() == DialogResult.OK)
     {
         txtXSD.Text = opf.FileName;
         xb          = new XMLBuilder();
         xb.LoadXSD(txtXSD.Text);
         LoadTree();
     }
 }
Пример #2
0
        private void cmdLoadMap_Click(object sender, EventArgs e)
        {
            opf.Filter           = "XML files|*.xml|All files|*.*";
            opf.Title            = "Настройки генерации (XML)";
            opf.InitialDirectory = Properties.Settings.Default.MAPFolder;
            opf.CheckFileExists  = true;
            opf.FileName         = "";
            if (opf.ShowDialog() == DialogResult.OK)
            {
                xb = new XMLBuilder();
                using (var stream = System.IO.File.OpenRead(opf.FileName))
                {
                    var serializer = new XmlSerializer(typeof(xsdItem));
                    xb.root = serializer.Deserialize(stream) as xsdItem;
                }

                xb.root.RestoreParent();
                LoadTree();
            }
        }
Пример #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (txtXSLT.Text == "")
            {
                MessageBox.Show("Надо задать путь к XSLT файлу");
                return;
            }
            if (txtMap.Text == "")
            {
                MessageBox.Show("Надо задать путь к файлу настроек");
                return;
            }
            this.UseWaitCursor = true;
            Cursor.Current     = Cursors.WaitCursor;

            xb = new XMLBuilder();
            FileInfo fi = new FileInfo(txtMap.Text);

            string OutputFolder = fi.DirectoryName;

            if (Properties.Settings.Default.OutputFolder != "")
            {
                if (Directory.Exists(Properties.Settings.Default.OutputFolder))
                {
                    OutputFolder = Properties.Settings.Default.OutputFolder;
                }
            }

            xb.OutFolder = OutputFolder;

            using (var stream = System.IO.File.OpenRead(txtMap.Text))
            {
                var serializer = new XmlSerializer(typeof(xsdItem));
                xb.root = serializer.Deserialize(stream) as xsdItem;
            }

            xb.root.RestoreParent();

            string xmlPath = xb.BuildXML(xb.root, txtGenPaths.Text.Trim());

            txtGen2.Text = xmlPath;
            string htmlPath = OutputFolder + "\\" + xb.root.Name + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".html";
            string errPath  = OutputFolder + "\\" + xb.root.Name + "_ERROR_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";

            var input  = new FileInfo(xmlPath);
            var output = new FileInfo(htmlPath);

            try
            {
                // Compile stylesheet
                var processor  = new Processor();
                var compiler   = processor.NewXsltCompiler();
                var executable = compiler.Compile(new Uri(txtXSLT.Text));

                // Do transformation to a destination
                var destination = new DomDestination();
                using (var inputStream = input.OpenRead())
                {
                    var transformer = executable.Load();
                    transformer.SetInputStream(inputStream, new Uri(input.FullName));
                    transformer.Run(destination);
                }
                destination.XmlDocument.Save(output.FullName);

                CheckHTML(output.FullName, errPath);
            }
            catch (Saxon.Api.DynamicError sad)
            {
                //txtError.Text = ex.Message + "(" + ex.LineNumber.ToString() + ")";
                txtError.Text = sad.Message + "(" + sad.LineNumber + ")";
            }
            catch (System.Exception ex)
            {
                txtError.Text = ex.Message;
            }

            this.UseWaitCursor = false;
            Cursor.Current     = Cursors.Default;
        }
Пример #4
0
        private void cmdRun_Click(object sender, EventArgs e)
        {
            if (txtXSLT.Text == "")
            {
                MessageBox.Show("Надо задать путь к XSLT файлу");
                return;
            }

            if (txtXSD.Text == "")
            {
                MessageBox.Show("Надо задать путь к XSD файлу");
                return;
            }

            this.UseWaitCursor = true;
            Cursor.Current     = Cursors.WaitCursor;

            xb = new XMLBuilder();
            FileInfo fi = new FileInfo(txtXSD.Text);

            string OutputFolder = fi.DirectoryName;

            if (Properties.Settings.Default.OutputFolder != "")
            {
                if (Directory.Exists(Properties.Settings.Default.OutputFolder))
                {
                    OutputFolder = Properties.Settings.Default.OutputFolder;
                }
            }

            xb.XSDPath   = txtXSD.Text;
            xb.OutFolder = OutputFolder;


            List <string> genpaths = new List <string>();
            String        sPaths   = "";

            if (tvPath.Nodes.Count > 0)
            {
                foreach (TreeNode n in tvPath.Nodes)
                {
                    if (n.Checked)
                    {
                        if (!genpaths.Contains((String)(n.Tag)))
                        {
                            genpaths.Add((String)(n.Tag));
                        }
                        CollectChildPath(genpaths, n);
                    }
                }

                foreach (string s in genpaths)
                {
                    sPaths += (s + "\r");
                }
            }
            else
            {
                sPaths = txtGenPaths.Text.Trim();
            }

            System.Diagnostics.Debug.Print(sPaths);


            string xmlPath = xb.BuildXML(sPaths);

            txtGen1.Text = xmlPath;

            string htmlPath = OutputFolder + "\\" + xb.root.Name + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".html";
            string errPath  = OutputFolder + "\\" + xb.root.Name + "_ERROR_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";

            var input  = new FileInfo(xmlPath);
            var output = new FileInfo(htmlPath);

            try
            {
                // Compile stylesheet
                var processor  = new Processor();
                var compiler   = processor.NewXsltCompiler();
                var executable = compiler.Compile(new Uri(txtXSLT.Text));

                // Do transformation to a destination
                var destination = new DomDestination();
                using (var inputStream = input.OpenRead())
                {
                    var transformer = executable.Load();
                    transformer.SetInputStream(inputStream, new Uri(input.FullName));
                    transformer.Run(destination);
                }
                destination.XmlDocument.Save(output.FullName);

                CheckHTML(output.FullName, errPath);
            } catch (System.Exception ex)
            {
                txtError.Text = ex.Message;
            }

            this.UseWaitCursor = false;
            Cursor.Current     = Cursors.Default;
        }
Пример #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (txtXSLT.Text == "")
            {
                MessageBox.Show("Надо задать путь к XSLT файлу");
                return;
            }

            if (txtXML.Text == "")
            {
                MessageBox.Show("Надо задать путь к XML файлу");
                return;
            }
            this.UseWaitCursor = true;
            Cursor.Current     = Cursors.WaitCursor;
            xb = new XMLBuilder();
            FileInfo fi = new FileInfo(txtXML.Text);

            string OutputFolder = fi.DirectoryName;

            if (Properties.Settings.Default.OutputFolder != "")
            {
                if (Directory.Exists(Properties.Settings.Default.OutputFolder))
                {
                    OutputFolder = Properties.Settings.Default.OutputFolder;
                }
            }

            string xmlPath = txtXML.Text;
            string Name    = fi.Name.Replace(fi.Extension, "");

            string htmlPath = OutputFolder + "\\" + Name + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".html";
            string errPath  = OutputFolder + "\\" + Name + "_ERROR_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt";

            var input  = new FileInfo(xmlPath);
            var output = new FileInfo(htmlPath);

            try
            {
                // Compile stylesheet
                var processor  = new Processor();
                var compiler   = processor.NewXsltCompiler();
                var executable = compiler.Compile(new Uri(txtXSLT.Text));

                // Do transformation to a destination
                var destination = new DomDestination();
                using (var inputStream = input.OpenRead())
                {
                    var transformer = executable.Load();
                    transformer.SetInputStream(inputStream, new Uri(input.DirectoryName));
                    transformer.Run(destination);
                }
                destination.XmlDocument.Save(output.FullName);

                CheckHTML(output.FullName, errPath);
            } catch (System.Exception ex)
            {
                txtError.Text = ex.Message;
            }
            this.UseWaitCursor = false;
            Cursor.Current     = Cursors.Default;
        }