Exemplo n.º 1
0
        public async Task <string> ConvertXml2Html(string OriginalxmlFile, string ToLanguage, string FileName)
        {
            if (File.Exists(ToLanguage + "-stylesheet-ubl.xslt"))
            {
            }
            else
            {
                string originalxsltFile = File.ReadAllText("stylesheet-ubl v2.xslt");

                string result = await GetXsltTranslated4Labels(originalxsltFile, ToLanguage, "English");

                result = await GetXsltTranslated4CountryID(OriginalxmlFile, result, ToLanguage);

                File.WriteAllText(ToLanguage + "-stylesheet-ubl.xslt", result);
            }

            string translatedXmlNote = await GetXmlTranslated4Note(OriginalxmlFile, ToLanguage, "English");

            string translatedXmlNames = await GetXmlTranslated4Names(translatedXmlNote, ToLanguage, "English");

            File.WriteAllText(ToLanguage + "-" + "TranslatedFile.xml", translatedXmlNames);


            string HTMLstring = XSLThelper.SaxonTransform(ToLanguage + "-stylesheet-ubl.xslt", ToLanguage + "-" + FileName);


            // get rid of the xslt bugs
            HTMLstring = HTMLstring.Replace("<div class=\"col-md-5\" />", "");

            HTMLstring = HTMLstring.Replace("<div class=\"col-sm-4\" />", "");

            HTMLstring = HTMLstring.Replace("<div />", "");
            HTMLstring = HTMLstring.Replace("style=\"width: 20%;\"", "class=\"text-right\"");
            HTMLstring = HTMLstring.Replace("linesupport{background-color:#eee", "linesupport{");
            HTMLstring = HTMLstring.Replace("<div class=\"col-sm-9\">Price</div>", "");
            return(HTMLstring);
        }
Exemplo n.º 2
0
        private async void btnLoadXML_Click(object sender, RoutedEventArgs e)
        {
            if (btnLoadXML.IsEnabled == false)
            {
                MessageBox.Show("no xml file loaded");
                return;
            }

            btnSaveXSLT.Visibility = Visibility.Hidden;
            btnSave_XML.Visibility = Visibility.Hidden;


            string OriginalxmlFile  = File.ReadAllText(openFileDialog.FileName);//("cleaning services.xml");
            string OriginalxsltFile = File.ReadAllText("stylesheet-ubl v2.xslt");

            string result = await GetXsltTranslated4Labels(OriginalxsltFile, ToLanguageComboBox.Text);

            result = await GetXsltTranslated4CountryID(OriginalxmlFile, result, ToLanguageComboBox.Text);

            File.WriteAllText(ToLanguageComboBox.Text + "-stylesheet-ubl.xslt", result);
            //  string HTMLstring = XLSThelper.TransformXMLToHTML(File.ReadAllText("cleaning services.xml"), File.ReadAllText("stylesheet-ubl.xslt"));


            string TranslatedXmlNote = await GetXmlTranslated4Note(OriginalxmlFile, ToLanguageComboBox.Text);

            string TranslatedXmlNames = await GetXmlTranslated4Names(TranslatedXmlNote, ToLanguageComboBox.Text);

            File.WriteAllText(ToLanguageComboBox.Text + "-" + Path.GetFileName(openFileDialog.FileName), TranslatedXmlNames);

            string HTMLstring = XSLThelper.SaxonTransform(ToLanguageComboBox.Text + "-stylesheet-ubl.xslt", ToLanguageComboBox.Text + "-" + Path.GetFileName(openFileDialog.FileName));


            //string Labels2Translate = File.ReadAllText("Labels2Translate.txt");


            //await translate(Labels2Translate);

            //string[] Translatedlines = translation.Split(
            //    new[] { Environment.NewLine },
            //    StringSplitOptions.None
            //    );
            //string[] originalLines = Labels2Translate.Split(
            //    new[] { Environment.NewLine },
            //    StringSplitOptions.None
            //    );
            //
            HTMLstring = HTMLstring.Replace("<div class=\"col-md-5\" />", "");
            //<div class="col-sm-4" />
            HTMLstring = HTMLstring.Replace("<div class=\"col-sm-4\" />", "");

            //for (int i = 0; i < Translatedlines.Length; i++)
            //{
            //    if(Translatedlines[i] != "")
            //    HTMLstring = HTMLstring.Replace(">" + originalLines[i] + "<", ">" + Translatedlines[i] + "<");

            //}


            File.WriteAllText("eInvoice.html", HTMLstring);
            System.Diagnostics.Process.Start("eInvoice.html");

            btnSaveXSLT.Visibility = Visibility.Visible;
            btnSave_XML.Visibility = Visibility.Visible;


            // Update the translation field
            //TranslatedTextLabel.Content = translation;

            //InvoiceDisplay invoiceDisplay = new InvoiceDisplay();

            // invoiceDisplay.wbInvoice.NavigateToString(HTMLstring);
            // invoiceDisplay.Show();
        }