private void button3_Click(object sender, EventArgs e) { if (txtOutput.Text == "") { MessageBox.Show("Не задана папка для сохранения"); return; } if (xb == null || xb.root == null) { MessageBox.Show("Не загружена информация для генерации"); return; } if (txtOutput.Text != "" && xb != null && xb.root != null) { xb.OutFolder = txtOutput.Text; xb.BuildXML(xb.root, ""); } }
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; }
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; }