Exemplo n.º 1
0
        public override void TransformFileToFile(XMLUtilities.XSLParameter[] parameterList, string sInputPath, string sOutputName)
        {
            try
            {

                // Add any parameters
                AddParameters(parameterList);

                // apply transform
                var inputUri = new Uri(sInputPath);
                var sr = new StreamReader(sInputPath, Encoding.UTF8);
                XdmNode inputNode = m_processor.NewDocumentBuilder().Build(inputUri);
                sr.Close();
                m_transformer.InitialContextNode = inputNode;

                var ser = new Serializer();
                ser.SetOutputFile(sOutputName);

                m_transformer.Run(ser);
                ser.Close();
            }
            catch (Exception e)
            {
                MessageBox.Show(e.InnerException.ToString());
            }
        }
Exemplo n.º 2
0
 public override void TransformFileToFile(XMLUtilities.XSLParameter[] parameterList, string sInputPath, string sOutputName)
 {
     m_xmlDoc.load(sInputPath);
     m_xslProc = m_xslt.createProcessor();
     m_xslProc.input = m_xmlDoc;
     AddParameters(parameterList);
     m_xslProc.transform();
     StreamWriter sr = File.CreateText(sOutputName);
     sr.Write(m_xslProc.output);
     sr.Close();
 }
Exemplo n.º 3
0
 /// <summary>
 /// Add parameters to a transform
 /// </summary>
 /// <param name="parameterList"></param>
 /// <param name="xslProc"></param>
 private void AddParameters(XMLUtilities.XSLParameter[] parameterList)
 {
     if (parameterList != null)
     {
         foreach (XMLUtilities.XSLParameter rParam in parameterList)
         {
             // Following is a specially recognized parameter name
             if (rParam.Name == "prmSDateTime")
             {
                 m_xslProc.addParameter(rParam.Name, XMLUtilities.GetCurrentDateTime(CultureToUse), "");
             }
             else
                 m_xslProc.addParameter(rParam.Name, rParam.Value, "");
         }
     }
 }
 private void AddParameters(out XsltArgumentList args, XMLUtilities.XSLParameter[] parameterList)
 {
     args = new XsltArgumentList();
     if (parameterList != null)
     {
         foreach (XMLUtilities.XSLParameter rParam in parameterList)
         {
             // Following is a specially recognized parameter name
             if (rParam.Name == "prmSDateTime")
             {
                 args.AddParam(rParam.Name, "", XMLUtilities.GetCurrentDateTime(CultureToUse));
             }
             else
                 args.AddParam(rParam.Name, "", rParam.Value);
         }
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Add parameters to a transform
 /// </summary>
 /// <param name="parameterList"></param>
 /// <param name="xslProc"></param>
 private void AddParameters(XMLUtilities.XSLParameter[] parameterList)
 {
     if (parameterList != null)
     {
         foreach (XMLUtilities.XSLParameter rParam in parameterList)
         {
             // Following is a specially recognized parameter name
             if (rParam.Name == "prmSDateTime")
             {
                 m_xslProc.addParameter(rParam.Name, XMLUtilities.GetCurrentDateTime(CultureToUse), "");
             }
             else
             {
                 m_xslProc.addParameter(rParam.Name, rParam.Value, "");
             }
         }
     }
 }
 private void AddParameters(out XsltArgumentList args, XMLUtilities.XSLParameter[] parameterList)
 {
     args = new XsltArgumentList();
     if (parameterList != null)
     {
         foreach (XMLUtilities.XSLParameter rParam in parameterList)
         {
             // Following is a specially recognized parameter name
             if (rParam.Name == "prmSDateTime")
             {
                 args.AddParam(rParam.Name, "", XMLUtilities.GetCurrentDateTime(CultureToUse));
             }
             else
             {
                 args.AddParam(rParam.Name, "", rParam.Value);
             }
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Add parameters to a transform
        /// </summary>
        /// <param name="parameterList"></param>
        /// <param name="xslProc"></param>
        private void AddParameters(XMLUtilities.XSLParameter[] parameterList)
        {
            if (parameterList != null)
            {
                foreach (XMLUtilities.XSLParameter rParam in parameterList)
                {
                    var parameterName = new QName(rParam.Name);

                    // Following is a specially recognized parameter name
                    if (rParam.Name == "prmSDateTime")
                    {
                        var parameterValue = new XdmAtomicValue((new QName(XMLUtilities.GetCurrentDateTime(CultureToUse))));
                        m_transformer.SetParameter(parameterName, parameterValue);
                    }
                    else
                    {
                        var parameterValue = new XdmAtomicValue((new QName(rParam.Value)));
                        m_transformer.SetParameter(parameterName, parameterValue);
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Add parameters to a transform
        /// </summary>
        /// <param name="parameterList"></param>
        /// <param name="xslProc"></param>
        private void AddParameters(XMLUtilities.XSLParameter[] parameterList)
        {
            if (parameterList != null)
            {
                foreach (XMLUtilities.XSLParameter rParam in parameterList)
                {
                    var parameterName = new QName(rParam.Name);

                    // Following is a specially recognized parameter name
                    if (rParam.Name == "prmSDateTime")
                    {
                        var parameterValue = new XdmAtomicValue((new QName(XMLUtilities.GetCurrentDateTime(CultureToUse))));
                        m_transformer.SetParameter(parameterName, parameterValue);
                    }
                    else
                    {
                        var parameterValue = new XdmAtomicValue((new QName(rParam.Value)));
                        m_transformer.SetParameter(parameterName, parameterValue);
                    }
                }
            }
        }
        public override void TransformFileToFile(XMLUtilities.XSLParameter[] parameterList, string sInputPath, string sOutputName)
        {
            #if DEBUG
            DateTime start = DateTime.Now;
            Debug.WriteLine("\tStarting at: " + start.TimeOfDay.ToString());
            #endif
            TextWriter writer = null;
            XmlTextReader reader = null;
            try
            {
                // add any parameters
                XsltArgumentList args;
                AddParameters(out args, parameterList);

                // setup output file
                writer = File.CreateText(sOutputName);

                // load input file
                reader = new XmlTextReader(sInputPath) { ProhibitDtd = false, EntityHandling = EntityHandling.ExpandEntities };

                // Apply transform
                m_transformer.Transform(reader, args, writer);
            }
            finally
            {
                if (writer != null)
                    writer.Close();
                if (reader != null)
                    reader.Close();
            }
            #if DEBUG
            DateTime end = DateTime.Now;
            Debug.WriteLine("\tEnding at: " + end.TimeOfDay.ToString());
            System.TimeSpan diff = end.Subtract(start);
            Debug.WriteLine("\tProcess took: " + diff.ToString() + " " + sOutputName);
            #endif
        }
Exemplo n.º 10
0
 private string DetermineResultFile1(XMLUtilities.XSLParameter[] parameters)
 {
     string sResult = ResultFile1;
     for (int i = 0; i < parameters.Length; i++)
     {
         if (parameters[i].Name == sResult)
         {
             sResult = parameters[i].Value;
             break;
         }
     }
     return sResult;
 }
Exemplo n.º 11
0
 private string BuildResultFileName(string sLanguageAbbreviation, XMLUtilities.XSLParameter[] parameters)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(Path.Combine(ResultPath, sLanguageAbbreviation));
     sb.Append(DetermineResultFile1(parameters));
     sb.Append(ResultFile2);
     string sResultFile = sb.ToString();
     if (FileExtension != null && sResultFile != null)
     {
         int iExtensionStart = sResultFile.LastIndexOf(".") + 1;
         if ((iExtensionStart > 0) &&
             (FileExtension != sResultFile.Substring(iExtensionStart)))
         {
             sResultFile = sResultFile.Substring(0, iExtensionStart) + FileExtension;
         }
         else if (iExtensionStart == 0)
         {
             sResultFile = sResultFile + "." + FileExtension;
         }
     }
     return sResultFile;
 }
Exemplo n.º 12
0
 public abstract void TransformFileToFile(XMLUtilities.XSLParameter[] parameterList, string sInputPath, string sOutputName);
Exemplo n.º 13
0
 private static void CheckParameterNameValue(XMLUtilities.XSLParameter parameter, string sExpectedName, string sExpectedValue, string sMessage)
 {
     string sName = parameter.Name;
     Assert.AreEqual(sExpectedName, sName, sMessage + " name");
     string sValue = parameter.Value;
     Assert.AreEqual(sExpectedValue, sValue, sMessage + " value");
 }