Exemple #1
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);
            }
        }
        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 = FileUtils.GetTempFile("xml");

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

            if (XmlUtils.UsingDotNetTransforms())
            {
                sExpected = "ResultWithParams.xml";
            }
            else
            {
                sExpected = "ResultWithParamsMSXML2.xml";
            }
            if (Environment.OSVersion.Platform == PlatformID.Unix)             // Mono puts a newline in a different place
            {
                sExpected = "ResultWithParams-Linux.xml";
            }
            CheckXmlEquals(Path.Combine(m_sTestPath, sExpected), sResult);
            if (File.Exists(sResult))
            {
                File.Delete(sResult);
            }
        }
Exemple #3
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);
		}
Exemple #4
0
		private XmlUtils.XSLParameter[] GetParameters(int cParams, XmlNode rNode)
		{
			XmlUtils.XSLParameter[] parameterList = new XmlUtils.XSLParameter[cParams];
			int i = 0;
			foreach (XmlNode rParamNode in rNode.ChildNodes)
			{
				if (rParamNode.Name == "param")
				{
					string sName = XmlUtils.GetManditoryAttributeValue(rParamNode, "name");
					string sValue = XmlUtils.GetManditoryAttributeValue(rParamNode, "value");
					if (sValue == "TransformDirectory")
					{
						sValue = TransformPath;
					}
					parameterList[i] = new XmlUtils.XSLParameter(sName, sValue);
					i++;
				}
			}
			return parameterList;
		}