protected void LoadProperties(string source)
 {
     XmlDocument document = new XmlDocument();
     document.LoadXml(source);
     XmlNodeList elementsByTagName = document.GetElementsByTagName("Property");
     this.mPropertyDoc = (XmlDocument) document.Clone();
     XmlElement element = this.mPropertyDoc.CreateElement("properties");
     string str = "";
     XmlNode newChild = null;
     foreach (XmlNode node2 in elementsByTagName)
     {
         XmlAttribute namedItem = (XmlAttribute) node2.Attributes.GetNamedItem("control");
         if (str != namedItem.Value)
         {
             newChild = element.OwnerDocument.CreateElement(namedItem.Value);
             element.AppendChild(newChild);
             str = namedItem.Value;
         }
         XmlElement element2 = newChild.OwnerDocument.CreateElement("Property");
         for (int i = 0; i < node2.Attributes.Count; i++)
         {
             element2.SetAttribute(node2.Attributes[i].Name, node2.Attributes[i].Value);
         }
         newChild.AppendChild(element2);
     }
     this.Controls = new ControlCollection(element.ChildNodes);
 }
示例#2
0
        /// <inheritdoc />
        public override void Apply(XmlDocument document, string key)
        {
            foreach(IEnumerable<BuildComponentCore> branch in branches)
            {
                XmlDocument subdocument = document.Clone() as XmlDocument;

                foreach(BuildComponentCore component in branch)
                    component.Apply(subdocument, key);
            }
        }
示例#3
0
    /*******************************/

    public static System.Xml.XmlDocument ParseDocument(System.Xml.XmlDocument document, XmlSourceSupport source)
    {
        if (source.Characters != null)
        {
            document.Load(source.Characters.BaseStream);
            return((System.Xml.XmlDocument)document.Clone());
        }
        if (source.Bytes != null)
        {
            document.Load(source.Bytes);
            return((System.Xml.XmlDocument)document.Clone());
        }
        if (source.Uri != null)
        {
            document.Load(source.Uri);
            return((System.Xml.XmlDocument)document.Clone());
        }
        throw new System.Xml.XmlException("The XmlSource class can't be null");
    }
示例#4
0
        public static string writeStrict(XmlDocument original)
        {
            Debug.Assert(original.DocumentType == null);
            const string DocType = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">";
            var document = (XmlDocument)original.Clone();
            addHTMLStringNamespaceToRootElement(document);

            using (var stringWriter = new StringWriter())
            {
                using (var textWriter = new XHTMLTextWriter(stringWriter))
                {
                    document.WriteTo(textWriter);
                }

                return DocType + stringWriter;
            }
        }
示例#5
0
        //--- Class Methods ---
        private static void Test(string name, XmlRender xmlRender, CaseFolding caseFolding, string doctype, bool format) {
            string source;
            string expected;
            ReadTest(name, out source, out expected);
            expected = expected.Trim().Replace("\r", "");
            string actual;

            // determine how the document should be written back
            XmlReaderTestCallback callback;
            switch(xmlRender) {
            case XmlRender.Doc:

                // test writing sgml reader using xml document load
                callback = (reader, writer) => {
                    var doc = new XmlDocument();
                    doc.Load(reader);
                    doc.WriteTo(writer);
                };
                break;
            case XmlRender.DocClone:

                // test writing sgml reader using xml document load and clone
                callback = (reader, writer) => {
                    var doc = new XmlDocument();
                    doc.Load(reader);
                    var clone = doc.Clone();
                    clone.WriteTo(writer);
                };
                break;
            case XmlRender.Passthrough:

                // test writing sgml reader directly to xml writer
                callback = (reader, writer) => {
                    reader.Read();
                    while(!reader.EOF) {
                        writer.WriteNode(reader, true);
                    }
                };
                break;
            default:
                throw new ArgumentException("unknown value", "xmlRender");
            }
            actual = RunTest(caseFolding, doctype, format, source, callback);
            Assert.AreEqual(expected, actual);
        }
示例#6
0
 public static void loadLevel(ContentManager c, String path)
 {
     c.clear();
     XmlDocument reader = new XmlDocument();
     reader.Load(path);
     int id = 0;
     float[] blockInfo = new float[4];
     foreach(XmlNode node in reader.DocumentElement)
     {
         foreach(XmlNode child in node.ChildNodes)
         {
             id = int.Parse(child.Attributes[0].Value);
             blockInfo[0] = float.Parse(child.Attributes[1].Value);
             blockInfo[1] = float.Parse(child.Attributes[2].Value);
             blockInfo[2] = float.Parse(child.Attributes[3].Value);
             blockInfo[3] = float.Parse(child.Attributes[4].Value);
             loadBlock(id, blockInfo, c);
         }
     }
     reader.Clone();
 }
示例#7
0
        public IXPathNavigable GetAllProcessRuns(int processId, ProcessType processType) {

            DataTable subComponents = this.m_model.GetChildComponents(processId);

            XmlDocument doc = new XmlDocument();
            XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", String.Empty);
            doc.AppendChild(declaration);

            String rootName = String.Empty;
            String runName = String.Empty;
            switch (processType) {
                case ProcessType.OPTIMIZATION:
                    rootName = "Optimization";
                    runName = "OptRun";
                    break;
                case ProcessType.SIMULATION:
                    rootName = "Simulation";
                    runName = "SimRun";
                    break;
                default:
                    throw new Exception("The Process Type is not defined in the ProcessControllType enum");
            }

            XmlElement root = doc.CreateElement(rootName);
            root.SetAttribute("id", processId.ToString());
            doc.AppendChild(root);

            int id;
            String name;
            DataTable parameters;
            XmlElement runNode;
            foreach (DataRow simRunRows in subComponents.Rows) {
                id = (int)simRunRows[SchemaConstants.Id];
                runNode = doc.CreateElement(runName);
                runNode.SetAttribute("id", id.ToString());

                name = simRunRows[SchemaConstants.Name].ToString();
                runNode.SetAttribute("name", name);
                root.AppendChild(runNode);

                parameters = this.m_model.GetParameterTable(id, eParamParentType.Component.ToString());
                XmlElement parameterNode;
                String parameterId, parameterName, parameterValue;
                foreach (DataRow parameterRows in parameters.Rows) {
                    parameterId = parameterRows[SchemaConstants.Id].ToString();
                    parameterName = parameterRows[SchemaConstants.Name].ToString();
                    parameterValue = parameterRows[SchemaConstants.Value].ToString();
                    parameterNode = doc.CreateElement("Parameter");
                    parameterNode.SetAttribute("name", parameterName);
                    parameterNode.SetAttribute("value", parameterValue);
                    runNode.AppendChild(parameterNode);
                }
            }

            return doc.Clone();
        }
示例#8
0
        /// <summary>
        /// Inserta un contenido XML para generar una firma enveloping.
        /// </summary>
        /// <param name="xmlDocument"></param>
        public void SetContentEveloping(XmlDocument xmlDocument)
        {
            Reference reference = new Reference();

            _xadesSignedXml = new XadesSignedXml();

            XmlDocument doc = (XmlDocument)xmlDocument.Clone();
            doc.PreserveWhitespace = true;

            if (doc.ChildNodes[0].NodeType == XmlNodeType.XmlDeclaration)
            {
                doc.RemoveChild(doc.ChildNodes[0]);
            }

            //Add an object
            string dataObjectId = "DataObject-" + Guid.NewGuid().ToString();
            System.Security.Cryptography.Xml.DataObject dataObject = new System.Security.Cryptography.Xml.DataObject();
            dataObject.Data = doc.ChildNodes;
            dataObject.Id = dataObjectId;
            _xadesSignedXml.AddObject(dataObject);

            reference.Id = "Reference-" + Guid.NewGuid().ToString();
            reference.Uri = "#" + dataObjectId;
            reference.Type = SignedXml.XmlDsigNamespaceUrl + "Object";

            XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
            reference.AddTransform(transform);

            _objectReference = reference.Id;
            _mimeType = "text/xml";

            _xadesSignedXml.AddReference(reference);

            _document = null;
        }
示例#9
0
        /// <summary>
        /// Carga el documento XML especificado y establece para firmar el elemento especificado en elementId
        /// </summary>
        /// <param name="xmlDocument"></param>
        /// <param name="elementId"></param>
        /// <param name="mimeType"></param>
        public void SetContentInternallyDetached(XmlDocument xmlDocument, string elementId, string mimeType)
        {
            _document = (XmlDocument)xmlDocument.Clone();
            _document.PreserveWhitespace = true;

            Reference reference = new Reference();

            reference.Uri = "#" + elementId;
            reference.Id = "Reference-" + Guid.NewGuid().ToString();

            _objectReference = reference.Id;
            _mimeType = mimeType;

            if (mimeType == "text/xml")
            {
                XmlDsigC14NTransform transform = new XmlDsigC14NTransform();
                reference.AddTransform(transform);
            }
            else
            {
                XmlDsigBase64Transform transform = new XmlDsigBase64Transform();
                reference.AddTransform(transform);
            }

            _xadesSignedXml = new XadesSignedXml(_document);

            _xadesSignedXml.AddReference(reference);
        }
示例#10
0
文件: Test.cs 项目: xxjeng/nuxleus
 void RunTest(SgmlReader reader, int line, string args, string input, string expectedOutput){
     bool testdoc = false;
     bool testclone = false;
     foreach (string arg in args.Split(' ')){
         string sarg = arg.Trim();
         if (sarg.Length==0) continue;
         if (sarg[0] == '-'){
             switch (sarg.Substring(1)){
                 case "html":
                     reader.DocType = "html";
                     break;
                 case "lower":
                     reader.CaseFolding = CaseFolding.ToLower;
                     break;
                 case "upper":
                     reader.CaseFolding = CaseFolding.ToUpper;
                     break;
                 case "testdoc":
                     testdoc = true;
                     break;
                 case "testclone":
                     testclone = true;
                     break;
             }
         }
     }
     this.tests++;
     reader.InputStream = new StringReader(input);
     reader.WhitespaceHandling = WhitespaceHandling.None;
     StringWriter output = new StringWriter();
     XmlTextWriter w = new XmlTextWriter(output);
     w.Formatting = Formatting.Indented;
     if (testdoc) {
         XmlDocument doc = new XmlDocument();
         doc.Load(reader);
         doc.WriteTo(w);
     } else if(testclone) {
         XmlDocument doc = new XmlDocument();
         doc.Load(reader);
         XmlNode clone = doc.Clone();
         clone.WriteTo(w);
     } else {
         reader.Read();
         while (!reader.EOF) {
             w.WriteNode(reader, true);
         }
     }            
     w.Close();
     string actualOutput = output.ToString();
     if (actualOutput.Trim() != expectedOutput.Trim()) {
         Console.WriteLine();
         Console.WriteLine("ERROR: Test failed on line {0}", line);
         Console.WriteLine("---- Expected output");
         Console.Write(expectedOutput);
         Console.WriteLine("---- Actual output");
         Console.WriteLine(actualOutput);
     } else {
         this.passed++;
     }
 }
示例#11
0
        /// <summary>
        /// Inserta un contenido XML para generar una firma enveloped.
        /// </summary>
        /// <param name="xmlDocument"></param>
        public void SetContentEnveloped(XmlDocument xmlDocument)
        {
            _document = (XmlDocument)xmlDocument.Clone();
            _document.PreserveWhitespace = true;

            CreateEnvelopedDocument();
        }
示例#12
0
        /// <summary>
        /// Loading config file
        /// </summary>
        /// <param name="xmlDoc"></param>
        private void loadICOMSConfiguration(XmlDocument xmlDoc)
        {
            try
            {
                logger.Info("ICOMSEditConfiguration::loadICOMSConfiguration() called");
                tvICOMSEditConfig.Nodes.Clear();

                tvICOMSEditConfig.Nodes.Add(getTreeNode("sites", "sites", "sites"));
                tvICOMSEditConfig.Nodes.Add(getTreeNode("CRMconnection", "CRMconnection", "CRMconnection"));
                tvICOMSEditConfig.Nodes.Add(getTreeNode("LoadBalancer", "LoadBalancer", "LoadBalancer"));

                tvICOMSEditConfig.SelectedNode = tvICOMSEditConfig.Nodes[0];
                XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/serviceconfiguration/sites/site");

                lstSiteIds.Clear();
                lstSiteNames.Clear();
                lstSiteIPAndPort.Clear();

                foreach (XmlNode nde in nodeList)
                {
                    tvICOMSEditConfig.SelectedNode.Nodes.Add(getTreeNode(nde.Attributes.GetNamedItem("id").Value, nde.Attributes.GetNamedItem("name").Value, "site"));
                    lstSiteIds.Add(nde.Attributes.GetNamedItem("id").Value);
                    lstSiteNames.Add(nde.Attributes.GetNamedItem("name").Value);
                    lstSiteIPAndPort.Add(nde["listenerAddress"].InnerText+nde["listenerPort"].InnerText);
                }

                logger.Info(string.Format("loadICOMSConfiguration():: Site Id List created  \"{0}\"", string.Join(",",lstSiteIds.ToArray())));
                logger.Info(string.Format("loadICOMSConfiguration():: Site Name List created \"{0}\"", string.Join(",",lstSiteNames.ToArray())));

                xmlDoc_ICOMS_Curr = (XmlDocument) xmlDoc.Clone();
                tvICOMSEditConfig.ExpandAll();
                tvICOMSEditConfig.Focus();
            }
            catch (XmlException xmlEx)
            {
                logger.Error(string.Format("loadICOMSConfiguration(): Err Msg: {0}", xmlEx.Message));
                logger.Error(string.Format("loadICOMSConfiguration(): Stack Trace: {0}", xmlEx.StackTrace));
                logger.Error("ICOMSEditConfiguration::loadICOMSConfiguration() throwing error");
            }
            catch (Exception ex)
            {
                logger.Error(string.Format("loadICOMSConfiguration(): Err Msg: {0}", ex.Message));
                logger.Error(string.Format("loadICOMSConfiguration(): Stack Trace: {0}", ex.StackTrace));
                logger.Error("ICOMSEditConfiguration::loadICOMSConfiguration() throwing error");
            }
        }
示例#13
0
        /// <summary>
        /// loading config file on form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmICOMSEditConfig_Load(object sender, EventArgs e)
        {
            logger.Info("ICOMSEditConfiguration::frmICOMSEditConfig_Load() called");
            try
            {
                xmlDoc_ICOMS_Curr = new XmlDocument();

                // --* path to load config file from exe path *--
              //  cnfgFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location) + ConfigurationManager.AppSettings["ICOMSXMLFILEPATH"];
               // cnfgFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + ConfigurationManager.AppSettings["ICOMSXMLFILEPATH"];
                // --* path to load config file from developemt exe path *--

               cnfgFilePath = "../../" + ConfigurationManager.AppSettings["ICOMSXMLFILEPATH"];

                xmlDoc_ICOMS_Curr.Load(cnfgFilePath);   //load the XMl file
                logger.Info(cnfgFilePath);
                xmlDoc_ICOMS_Def = (XmlDocument)xmlDoc_ICOMS_Curr.Clone();
                loadICOMSConfiguration(xmlDoc_ICOMS_Curr);
                isDirtyChanged = false;

            }
            catch (Exception ex)
            {
                logger.Error(string.Format("frmICOMSEditConfig_Load(): Err Msg: {0}", ex.Message));
                logger.Error(string.Format("frmICOMSEditConfig_Load(): Stack Trace: {0}", ex.StackTrace));
                logger.Error("ICOMSEditConfiguration::frmICOMSEditConfig_Load() throwing error");
            }
        }
        /// <summary>
        /// The load notes.
        /// </summary>
        /// <param name="path">
        /// The path.
        /// </param>
        private void LoadNotes(string path)
        {
            // Объявляем и забиваем файл в XML-документ
            var xd = new XmlDocument();
            using (var fs = new FileStream(path, FileMode.Open))
            {
                xd.Load(fs);
                curDoc = null;
                curDoc = (XmlDocument)xd.Clone();
            }

            FileName = Path.GetFileNameWithoutExtension(path); // сохраняем имя прочтенного файла
        }
示例#15
0
        public void Load()
        {
            #region INITIAL FILE LOAD

            XmlDocument configuration = new XmlDocument();
            configuration.Load(this.FileName);

            //clone initial configuration
            this.Xml = configuration.Clone();

            #endregion

            #region COMPONENTS

            //get components node
            var componentsNode = configuration.SelectSingleNode("Configuration/Components");

            //validate
            if (componentsNode == null)
                throw new ArgumentException("Skin components node not found in configuration file", "componentsNode");

            //load components
            this.LoadComponents(componentsNode);

            #endregion

            #region MODULES

            var modulesNode = configuration.SelectSingleNode("Configuration/Components/Modules");

            //validate
            if (componentsNode == null)
                throw new ArgumentException("Skin modules node not found in configuration file", "modulesNode");

            #region BUILT IN MODULES

            //temporary variable to hold component result
            UIComponent temComponent;

            #region MAINWINDOW

            var mainWindowNode = configuration.SelectSingleNode("Configuration/Components/Modules/MainWindow");

            //validate
            if (mainWindowNode == null)
                throw new ArgumentException("Main window node not found in configuration file", "componentsNode");

            //load main window
            if (this.TryLoadComponenet(mainWindowNode, out temComponent))
            {
                this.MainWindowComponent = temComponent;
            }

            #endregion

            #region TASKBAR

            var taskBarNode = (XmlElement)configuration.SelectSingleNode("Configuration/Components/Modules/TaskBar");

            //validate
            if (taskBarNode == null)
                throw new ArgumentException("Taskbar node not found in configuration file", "taskBarNode");

            if (this.TryLoadComponenet(taskBarNode, out temComponent))
            {
                this.TaskBarComponent = temComponent;
                this.InternalAdd(temComponent);
            }

            #endregion

            #region APPLIST

            var applicationListNode = (XmlElement)configuration.SelectSingleNode("Configuration/Components/Modules/ApplicationsList");

            //validate
            if (applicationListNode == null)
                throw new ArgumentException("ApplicationList node not found in configuration file", "applicationListNode");

            if (this.TryLoadComponenet(applicationListNode, out temComponent))
            {
                this.ApplicationListComponent = temComponent;
                this.InternalAdd(temComponent);
            }

            #endregion

            #region CONTROLBOX

            var controlBoxNode = (XmlElement)configuration.SelectSingleNode("Configuration/Components/Modules/ControlBox");

            //validate
            if (controlBoxNode == null)
                throw new ArgumentException("Control box node not found in configuration file", "controlBoxNode");

            if (this.TryLoadComponenet(controlBoxNode, out temComponent))
            {
                this.ControlBoxComponent = temComponent;
            }

            #endregion

            #endregion

            #endregion

            #region LAYOUTS

            var layoutsNode = configuration.SelectSingleNode("Configuration/Layouts");

            //validate
            if (layoutsNode == null)
                throw new ArgumentException("Skin layouts node not found in configuration file", "layoutsNode");

            this.LoadLayouts(layoutsNode);

            #endregion

            #region ASSEMBLIES

            var assembliesNode = configuration.SelectSingleNode("Configuration/Assemblies");

            //validate
            if (assembliesNode == null)
                throw new ArgumentException("Skin assemblies node not found in configuration file", "assembliesNode");

            this.LoadAssemblies(assembliesNode);

            #endregion
        }
示例#16
0
        /// <summary>
        /// Takes an xml doc and trims whitespace from its children and removes any newlines
        /// </summary>
        /// <param name="doc">
        /// The XmlDocument to format.
        /// </param>
        /// <returns>
        /// An XmlDocument nicely formatted.
        /// </returns>
        private static XmlDocument FormatXmlDocument(XmlDocument doc)
        {
            XmlDocument formattedDoc = (XmlDocument)doc.Clone();

            // merge consecutive text nodes so avoid handling whitespace between
            // those
            formattedDoc.Normalize();

            Queue<XmlNode> queue = new Queue<XmlNode>();
            queue.Enqueue(formattedDoc.DocumentElement);

            while (queue.Count > 0)
            {
                XmlNode currentNode = queue.Dequeue();
                XmlNodeList childNodes = currentNode.ChildNodes;
                for (int i = 0; i < childNodes.Count; ++i)
                {
                    XmlNode child = childNodes[i];
                    if (child.NodeType != XmlNodeType.Text)
                    {
                        queue.Enqueue(child);
                        continue;
                    }

                    string text = child.InnerText.TrimEnd().Replace(" \n", "\n");
                    text = text.Replace("\n ", "\n");
                    text = text.Replace("\n\n\n\n", " ");
                    text = text.Replace("\n\n\n", " ");
                    text = text.Replace("\n\n", " ");
                    text = text.Replace("\n", " ");

                    if (i != childNodes.Count - 1)
                    {
                        text = text + " ";
                    }

                    child.InnerText = text;
                }
            }

            return formattedDoc;
        }
示例#17
0
 public HtmlDom(XmlDocument domToClone)
 {
     _dom = (XmlDocument) domToClone.Clone();
 }
		public void PreserveWhitespace2 ()
		{
			XmlDocument doc = new XmlDocument ();
			Assert (!doc.PreserveWhitespace);
			doc.PreserveWhitespace = true;
			XmlDocument d2 = doc.Clone () as XmlDocument;
			Assert (!d2.PreserveWhitespace); // i.e. not cloned
			d2.AppendChild (d2.CreateElement ("root"));
			d2.DocumentElement.AppendChild (d2.CreateWhitespace ("   "));
			StringWriter sw = new StringWriter ();
			d2.WriteTo (new XmlTextWriter (sw));
			AssertEquals ("<root>   </root>", sw.ToString ());
		}
示例#19
0
 override public IXPathNavigable GetOutputXml(String filename)
 {
     XmlDocument document = new XmlDocument();
     try
     {
         String outputPath = Path.GetFullPath(configurationPath + @"\output");
         String outputFile = Path.Combine(outputPath, filename + ".xml");
         if (filename.Length > 0)
         {
             document.Load(outputFile);
         }
         return (IXPathNavigable)document.Clone();
     }
     catch (MySqlException ex)
     {
         MessageBox.Show(ex.Message, String.Format("Failed to get output xml '{0}'", filename));
         return null;
     }
 }
示例#20
0
        /// <inheritdoc />
        public override void Apply(XmlDocument document, string key)
        {
            foreach(var branch in branches)
            {
                XmlDocument subdocument = (XmlDocument)document.Clone();

                foreach(var component in branch)
                    component.Apply(subdocument, key);
            }
        }
示例#21
0
		private Stream ApplyTransform (Transform t, XmlDocument input) 
		{
			// These transformer modify input document, which should
			// not affect to the input itself.
			if (t is XmlDsigXPathTransform 
				|| t is XmlDsigEnvelopedSignatureTransform
				|| t is XmlDecryptionTransform
			)
				input = (XmlDocument) input.Clone ();

			t.LoadInput (input);

			if (t is XmlDsigEnvelopedSignatureTransform)
				// It returns XmlDocument for XmlDocument input.
				return CanonicalizeOutput (t.GetOutput ());

			object obj = t.GetOutput ();
			if (obj is Stream)
				return (Stream) obj;
			else if (obj is XmlDocument) {
				MemoryStream ms = new MemoryStream ();
				XmlTextWriter xtw = new XmlTextWriter (ms, Encoding.UTF8);
				((XmlDocument) obj).WriteTo (xtw);

				xtw.Flush ();

				// Rewind to the start of the stream
				ms.Position = 0;
				return ms;
			}
			else if (obj == null) {
				throw new NotImplementedException ("This should not occur. Transform is " + t + ".");
			}
			else {
				// e.g. XmlDsigXPathTransform returns XmlNodeList
				return CanonicalizeOutput (obj);
			}
		}
示例#22
0
            //the idea is, it searches through the document and finds items to switch out
            //it is called when needed by a user or programmer
            public XmlDocument ConvertFtToMeter(XmlDocument origdoc, XmlNamespaceManager gbXMLns1)
            {
                //number of feet in a meter
                double convrate = 3.280839895;

                XmlDocument retdoc = (XmlDocument)origdoc.Clone();
                //by default, I will always change these nodes because they are the minimum that must be presented


                //surface polyloop
                //surface lower left hand corner
                //building storeys
                XmlNodeList nodes = retdoc.SelectNodes("/gbXMLv5:gbXML/gbXMLv5:Campus/gbXMLv5:Building/gbXMLv5:BuildingStorey", gbXMLns1);
                if (nodes.Count > 0)
                {
                    foreach (XmlNode Node in nodes)
                    {
                        XmlNodeList childnodes = Node.ChildNodes;
                        foreach (XmlNode childnode in childnodes)
                        {
                            if (childnode.Name == "Level")
                            {
                                childnode.Value = Convert.ToString(Convert.ToDouble(childnode.Value) / convrate);
                            }
                            else if (childnode.Name == "PlanarGeometry")
                            {
                                //change the planar geometry
                                foreach (XmlNode PolyLoops in childnode)
                                {
                                    //gathers all the cartesian points in a given polyloop
                                    foreach (XmlNode cartesianPoints in PolyLoops)
                                    {
                                        foreach (XmlNode coordinate in cartesianPoints)
                                        {
                                            if (coordinate.Name == "Coordinate")
                                            {
                                                coordinate.Value = Convert.ToString(Convert.ToDouble(coordinate.Value) / convrate);
                                            }
                                            else
                                            {
                                                //this is bad, should terminate somehow
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                //space planar geometry
                //space shell geometry
                //space space boundaries
                XmlNodeList spacenodes = retdoc.SelectNodes("/gbXMLv5:gbXML/gbXMLv5:Campus/gbXMLv5:Building/gbXMLv5:Spaces", gbXMLns1);
                if (nodes.Count > 0)
                {
                    foreach (XmlNode Node in nodes)
                    {
                        XmlNodeList childnodes = Node.ChildNodes;
                        foreach (XmlNode childnode in childnodes)
                        {
                            if (childnode.Name == "PlanarGeometry")
                            {
                                //change the planar geometry
                                foreach (XmlNode PolyLoops in childnode)
                                {
                                    //gathers all the cartesian points in a given polyloop
                                    foreach (XmlNode cartesianPoints in PolyLoops)
                                    {
                                        foreach (XmlNode coordinate in cartesianPoints)
                                        {
                                            if (coordinate.Name == "Coordinate")
                                            {
                                                coordinate.Value = Convert.ToString(Convert.ToDouble(coordinate.Value) / convrate);
                                            }
                                            else
                                            {
                                                //this is bad, should terminate somehow
                                            }
                                        }
                                    }
                                }
                            }
                            else if (childnode.Name == "ShellGeometry")
                            {
                                //this should always be the ClosedShell element
                                XmlNode closedShell = childnode.FirstChild;
                                foreach (XmlNode PolyLoops in childnode)
                                {
                                    //gathers all the cartesian points in a given polyloop
                                    foreach (XmlNode cartesianPoints in PolyLoops)
                                    {
                                        foreach (XmlNode coordinate in cartesianPoints)
                                        {
                                            if (coordinate.Name == "Coordinate")
                                            {
                                                coordinate.Value = Convert.ToString(Convert.ToDouble(coordinate.Value) / convrate);
                                            }
                                            else
                                            {
                                                //this is bad, should terminate somehow
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                return retdoc;
            }
示例#23
0
        // this method can run on a worker thread! 
        private void CreateDocFromInlineXml(XmlReader xmlReader)
        { 
            // Maybe things have changed and we don't want to use inline doc anymore 
            if (!_tryInlineDoc)
            { 
                _savedDocument = null;
                if (_waitForInlineDoc != null)
                    _waitForInlineDoc.Set();
                return; 
            }
 
            XmlDocument doc; 
            Exception ex = null;
 
            try
            {
                doc = new XmlDocument();
                try 
                {
                    if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.XmlProvider)) 
                    { 
                        TraceData.Trace(TraceEventType.Warning,
                                            TraceData.XmlLoadInline( 
                                                TraceData.Identify(this),
                                                Dispatcher.CheckAccess() ? "synchronous" : "asynchronous"));
                    }
 
                    // Load the inline doc from the reader
                    doc.Load(xmlReader); 
                } 
                catch (XmlException xmle)
                { 
                    if (TraceData.IsEnabled)
                        TraceData.Trace(TraceEventType.Error, TraceData.XmlDPInlineDocError, xmle);
                    ex = xmle;
                } 

                if (ex == null) 
                { 
                    // Save a copy of the inline document to be used in future
                    // queries, and by serialization. 
                    _savedDocument = (XmlDocument)doc.Clone();
                }
            }
            finally 
            {
                xmlReader.Close(); 
                // Whether or not parsing was successful, unblock the serializer thread. 

                // If serializer had to wait for the inline doc, it's available now. 
                // If there was an error, null will be returned for DocumentForSerialization.
                if (_waitForInlineDoc != null)
                    _waitForInlineDoc.Set();
            } 

            // warn the user if the default xmlns wasn't set explicitly (bug 1006946) 
            if (TraceData.IsEnabled) 
            {
                XmlNode root = doc.DocumentElement; 
                if (root != null && root.NamespaceURI == xmlReader.LookupNamespace(String.Empty))
                {
                    TraceData.Trace(TraceEventType.Error, TraceData.XmlNamespaceNotSet);
                } 
            }
 
            if (ex == null) 
            {
                // Load succeeded.  Create the node collection.  (This calls 
                // OnQueryFinished to reset the Document and Data properties).
                BuildNodeCollection(doc);
            }
            else 
            {
                if (TraceData.IsExtendedTraceEnabled(this, TraceDataLevel.ProviderQuery)) 
                { 
                    TraceData.Trace(TraceEventType.Warning,
                                        TraceData.QueryFinished( 
                                            TraceData.Identify(this),
                                            Dispatcher.CheckAccess() ? "synchronous" : "asynchronous",
                                            TraceData.Identify(null),
                                            TraceData.IdentifyException(ex))); 
                }
 
                // Load failed.  Report the error, and reset 
                // Data and Document properties to null.
                OnQueryFinished(null, ex, CompletedCallback, null); 
            }
        }
示例#24
0
        /// <summary>
        /// loading config file on form load
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void frmICOMSEditConfig_Load(object sender, EventArgs e)
        {
            logger.Info("ICOMSEditConfiguration::frmICOMSEditConfig_Load() called");
            try
            {
                xmlDoc_ICOMS_Curr = new XmlDocument();
                cnfgFilePath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + GetConfigurationValue("ICOMSXMLFILEPATH");
                Uri path = new Uri(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + GetConfigurationValue("ICOMSXMLFILEPATH"));
                cnfgFilePath = path.LocalPath;
                xmlDoc_ICOMS_Curr.Load(cnfgFilePath);   //load the XMl file
                logger.Info(cnfgFilePath);
                xmlDoc_ICOMS_Def = (XmlDocument)xmlDoc_ICOMS_Curr.Clone();
                loadICOMSConfiguration(xmlDoc_ICOMS_Curr);
                isDirtyChanged = false;

            }
            catch (Exception ex)
            {
                logger.Error(string.Format("frmICOMSEditConfig_Load(): Err Msg: {0}", ex.Message));
                logger.Error(string.Format("frmICOMSEditConfig_Load(): Stack Trace: {0}", ex.StackTrace));
                logger.Error("ICOMSEditConfiguration::frmICOMSEditConfig_Load() throwing error");
            }
        }
示例#25
0
        void RunTest(SgmlReader reader, int line, string args, string input, string expectedOutput)
        {
            try {
                bool testdoc = false;
                bool testclone = false;
                bool format = true;
                bool ignore = false;
                foreach(string arg in args.Split(' ')) {
                    string sarg = arg.Trim();
                    if(sarg.Length == 0)
                        continue;
                    if(sarg[0] == '-') {
                        switch(sarg.Substring(1)) {
                        case "html":
                            reader.DocType = "html";
                            break;
                        case "lower":
                            reader.CaseFolding = CaseFolding.ToLower;
                            break;
                        case "upper":
                            reader.CaseFolding = CaseFolding.ToUpper;
                            break;
                        case "testdoc":
                            testdoc = true;
                            break;
                        case "testclone":
                            testclone = true;
                            break;
                        case "noformat":
                            format = false;
                            break;
                        case "ignore":
                            ignore = true;
                            break;
                        }
                    }
                }
                this.tests++;
                if(ignore) {
                    this.ignored++;
                    return;
                }
                reader.InputStream = new StringReader(input);
                if(format) {
                    reader.WhitespaceHandling = WhitespaceHandling.None;
                } else {
                    reader.WhitespaceHandling = WhitespaceHandling.All;
                }
                StringWriter output = new StringWriter();
                XmlTextWriter w = new XmlTextWriter(output);
                if(format) {
                    w.Formatting = Formatting.Indented;
                }
                if(testdoc) {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(reader);
                    doc.WriteTo(w);
                } else if(testclone) {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(reader);
                    XmlNode clone = doc.Clone();
                    clone.WriteTo(w);
                } else {
                    reader.Read();
                    while(!reader.EOF) {
                        w.WriteNode(reader, true);
                    }
                }
                w.Close();
                string actualOutput = output.ToString();

                // validate output
                using(StringReader source = new StringReader(actualOutput)) {
                    XmlDocument doc = new XmlDocument();
                    doc.Load(source);
                }

                // compare output
                if(actualOutput.Trim().Replace("\r", "") != expectedOutput.Trim().Replace("\r", "")) {
                    Console.WriteLine();
                    Console.WriteLine("ERROR: Test failed on line {0}", line);
                    Console.WriteLine("---- Expected output");
                    Console.Write(expectedOutput);
                    Console.WriteLine("---- Actual output");
                    Console.WriteLine(actualOutput);
                } else {
                    this.passed++;
                }
            } catch(Exception e) {
                Console.WriteLine("FATAL ERROR: Test threw an exception on line {0}", line);
                Console.WriteLine(e.Message);
                Console.WriteLine(e.ToString());
                Console.WriteLine("---- Input");
                Console.Write(input);
            }
        }
        //=====================================================================
        /// <summary>
        /// This is implemented to execute each set of components for the
        /// requested output formats.
        /// </summary>
        /// <param name="document">The XML document with which to work.</param>
        /// <param name="key">The key (member name) of the item being documented.</param>
        public override void Apply(XmlDocument document, string key)
        {
            XmlDocument clone;

            foreach(string format in formatComponents.Keys)
            {
                CurrentFormat = format;
                clone = (XmlDocument)document.Clone();

                foreach(BuildComponent component in formatComponents[format])
                    component.Apply(clone, key);
            }
        }
 /// <summary>
 /// The execute.
 /// </summary>
 /// <param name="xmlDocument">
 /// The xml document.
 /// </param>
 /// <param name="filename">
 /// The filename.
 /// </param>
 public void Execute(XmlDocument xmlDocument, string filename)
 {
     // TODO: проверка схемы Xml на соотвествие схеме MusicXml
     // создаем объект модели музыкального текста из Xml документа
     ScoreModel = new ScoreTrack(filename, ParseCongenericScoreTracks((XmlDocument)xmlDocument.Clone()));
 }
示例#28
0
 override public IXPathNavigable GetOutputXml(String filename)
 {
     XmlDocument document = new XmlDocument();
     String outputFilepath = Path.GetFullPath(configurationPath + @"\output");
     String simRunFile = Path.Combine(outputFilepath, filename + ".xml");
     if (filename.Length > 0)
     {
         document.Load(simRunFile);
     }
     return (IXPathNavigable)document.Clone();
 }