Beispiel #1
0
        public void TransformFileToFileNoParametersTest()
        {
            // set up transform (use local copy so don't have to keep it in sync with the real one)
            string sTransform = Path.Combine(m_sTestPath, "Test.xsl");
            // use local input file
            string sInput = Path.Combine(m_sTestPath, "Test.xml");
            // create temp output file
            string sResult = FwTempFile.CreateTempFileAndGetPath("xml");

            // do transform
            SIL.Utils.XmlUtils.TransformFileToFile(sTransform, sInput, sResult);
            // check results
            string sExpected;

            if (SIL.Utils.XmlUtils.UsingDotNetTransforms())
            {
                sExpected = "ResultNoParams.xml";
            }
            else
            {
                sExpected = "ResultNoParamsMSXML2.xml";
            }
            CheckXmlEquals(Path.Combine(m_sTestPath, sExpected), sResult);
            if (File.Exists(sResult))
            {
                File.Delete(sResult);
            }
        }
Beispiel #2
0
        public void TransformFileToFileWithParametersTest()
        {
            // set up transform (use local copy so don't have to keep it in sync with the real one)
            string sTransform = Path.Combine(m_sTestPath, "Test.xsl");

            // build parameter list
            XmlUtils.XSLParameter[] parameterList = new XmlUtils.XSLParameter[2];
            parameterList[0] = new XmlUtils.XSLParameter("prmiNumber", "10");
            parameterList[1] = new XmlUtils.XSLParameter("prmsNumber", "ten");
            // use local input file
            string sInput = Path.Combine(m_sTestPath, "Test.xml");
            // create temp output file
            string sResult = FwTempFile.CreateTempFileAndGetPath("xml");

            // do transform
            SIL.Utils.XmlUtils.TransformFileToFile(sTransform, parameterList, sInput, sResult);
            // check results
            string sExpected;

            if (SIL.Utils.XmlUtils.UsingDotNetTransforms())
            {
                sExpected = "ResultWithParams.xml";
            }
            else
            {
                sExpected = "ResultWithParamsMSXML2.xml";
            }
            CheckXmlEquals(Path.Combine(m_sTestPath, sExpected), sResult);
            if (File.Exists(sResult))
            {
                File.Delete(sResult);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Apply an XSLT transform on a DOM to produce a resulting file
        /// </summary>
        /// <param name="sTransformName">full path name of the XSLT transform</param>
        /// <param name="inputDOM">XmlDocument DOM containing input to be transformed</param>
        /// <param name="sOutputName">full path of the resulting output file</param>
        public static void TransformDomToFile(string sTransformName, XmlDocument inputDOM, string sOutputName)
        {
            string sTempInput = FwTempFile.CreateTempFileAndGetPath("xml");

            try
            {
                inputDOM.Save(sTempInput);
                SIL.Utils.XmlUtils.TransformFileToFile(sTransformName, sTempInput, sOutputName);
            }
            finally
            {
                if (File.Exists(sTempInput))
                {
                    File.Delete(sTempInput);
                }
            }
        }
Beispiel #4
0
 protected string CreateTempFile(string ext)
 {
     return(FwTempFile.CreateTempFileAndGetPath(ext));
 }