/// <summary> /// read the styles of the chart /// </summary> /// <param name="node"></param> /// <param name="styleType"></param> /// <returns></returns> public IStyle ReadStyle(XmlNode node,string styleType) { switch(styleType) { case "chart": return CreateChartStyle(node.CloneNode (true)); case "title": return CreateChartTitleStyle(node.CloneNode (true)); case "legend": return CreateChartLegendStyle(node.CloneNode (true)); case"plotarea": return CreateChartPlotAreaStyle(node.CloneNode (true)); case"axes": return CreateChartAxesStyle(node.CloneNode (true)); case"series": return CreateChartSeriesStyle(node.CloneNode (true)); case"wall": return CreateChartWallStyle(node.CloneNode (true)); case"floor": return CreateChartFloorStyle(node.CloneNode (true)); case "dr3d": //return CreateChartDr3dLightStyle(node.CloneNode (true)); default: return null; } }
protected void Page_Load(object sender, EventArgs e) { String adName = Request.QueryString["ad"]; String redirect = Request.QueryString["target"]; if (adName == null | redirect == null) { redirect = "AdRedirection.aspx"; } XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("AdResponses.xml")); System.Xml.XmlNode root = doc.DocumentElement; System.Xml.XmlNode adNode = root.SelectSingleNode( @"descendant::ad[@adname='" + adName + "']"); if (adNode != null) { int ctr = int.Parse(adNode.Attributes["hitCount"].Value); ctr += 1; System.Xml.XmlNode newAdNode = adNode.CloneNode(false); newAdNode.Attributes["hitCount"].Value = ctr.ToString(); root.ReplaceChild(newAdNode, adNode); doc.Save(Server.MapPath("AdResponses.xml")); } Response.Redirect(redirect); }
/// <summary> /// Creates the text object. /// </summary> /// <param name="document">The document.</param> /// <param name="aTextNode">A text node.</param> /// <returns></returns> public IText CreateTextObject(IDocument document, XmlNode aTextNode) { //aTextNode.InnerText = this.ReplaceSpecialCharacter(aTextNode.InnerText); int i=0; if (aTextNode.OuterXml.IndexOf("Contains state ") > -1) i++; switch(aTextNode.Name) { case "#text": return new SimpleText(document, aTextNode.InnerText); case "text:span": return CreateFormatedText(document, aTextNode); case "text:bookmark": return CreateBookmark(document, aTextNode , BookmarkType.Standard); case "text:bookmark-start": return CreateBookmark(document, aTextNode , BookmarkType.Start); case "text:bookmark-end": return CreateBookmark(document, aTextNode , BookmarkType.End); case "text:a": return CreateXLink(document, aTextNode); case "text:note": return CreateFootnote(document, aTextNode); case "text:line-break": return new LineBreak(document); case "text:s": return new WhiteSpace(document, aTextNode.CloneNode(true)); case "text:tab": return new TabStop(document); default: return null; } }
public HTMLDefinitionNode(XmlNode node, HTMLParserContext context) { m_sourceNode = node.CloneNode(true); m_name = node.Name; m_subNodes = new ArrayList(); m_attributes = new Dictionary<string, AttributeProperties>(); //Instead of dealing with xml nodes themselves its going to be easier to just deconstruct the whole thing, and recreate XML nodes in the final document decodeSourceNode(node, context); }
/// <summary> /// Takes a copy of the node and appends it to the selected /// node. /// </summary> void AppendChildCopy(XmlNode nodeToCopy) { if (nodeToCopy is XmlElement) { XmlElement copy = (XmlElement)nodeToCopy.CloneNode(true); AppendChildElement(copy); } else if (nodeToCopy is XmlText) { XmlText copy = (XmlText)nodeToCopy.CloneNode(true); AppendChildTextNode(copy); } else if (nodeToCopy is XmlComment) { XmlComment copy = (XmlComment)nodeToCopy.CloneNode(true); AppendChildComment(copy); } }
private InstanceMemento createNodeNormalizedMemento(XmlNode node) { XmlNode clonedNode = node.CloneNode(true); return new XmlNodeInstanceMemento(clonedNode, _typeAttribute, _keyAttribute); }
protected override void DeserializeElement (XmlReader reader, bool serializeCollectionKey) { original = new XmlDocument ().ReadNode (reader); node = original.CloneNode (true); }
/// <summary> /// Copy the row in table /// </summary> /// <param name="count">The times of copy</param> /// <param name="node">The node of row</param> protected void CopyRow(int count, XmlNode node, XmlNamespaceManager xmlmgr) { for (int i = 0; i < count; i++) { this.TagInfo = string.Format("Insert new row:{0}/{1}", i.ToString(), count.ToString()); XmlNode newNode = node.CloneNode(true); string rowname = "w:tc/w:p/w:r/w:t"; XmlNodeList nodelist = newNode.SelectNodes(rowname, xmlmgr); foreach (XmlNode nodecell in nodelist) { string strvalue = nodecell.InnerText.Trim(); if (strvalue.StartsWith("$") && strvalue.Contains("{0}")) { nodecell.InnerXml = nodecell.InnerXml.Replace(nodecell.InnerText, string.Format(strvalue, i.ToString())); } } ProcessTag(nodelist); node.ParentNode.InsertBefore(newNode, node); } node.ParentNode.RemoveChild(node); }
private TabPage NewTabPage(XmlNode xmlNode, bool isMain) { XmlNode inXmlNode = xmlNode.CloneNode(true); SetMillisecondsIntoXml(inXmlNode); if (inXmlNode.Attributes != null) { string s = inXmlNode.Attributes["elapsedMilliseconds"].Value.Replace(".", ","); SetPercentIntoXml(inXmlNode, double.Parse(s)); } var treePage = new TabPage {Height = tabControl.Height - 15, Width = tabControl.Width, Text = xmlNode.Name}; var treeView = new TreeView {Width = treePage.Width - 10, Height = treePage.Height - 10}; if (_dom.DocumentElement != null && isMain) { treeView.Nodes.Add(new TreeNode(_dom.DocumentElement.Name)); } else { treeView.Nodes.Add(new TreeNode(xmlNode.Name)); } TreeNode tNode = treeView.Nodes[0]; treeView.MouseClick += defTreeView_Click; AddNode(inXmlNode, tNode); treeView.ExpandAll(); treePage.Controls.Add(treeView); return treePage; }
/// <summary> /// Creates the section style. /// </summary> /// <param name="styleNode">The style node.</param> private void CreateSectionStyle(XmlNode styleNode) { SectionStyle sectionStyle = new SectionStyle(this._document, styleNode.CloneNode(true)); IPropertyCollection pCollection = new IPropertyCollection(); if (styleNode.HasChildNodes) { foreach(XmlNode node in styleNode.ChildNodes) { IProperty property = this.GetProperty(sectionStyle, node.CloneNode(true)); if (property != null) pCollection.Add(property); } } sectionStyle.Node.InnerXml = ""; foreach(IProperty property in pCollection) sectionStyle.PropertyCollection.Add(property); if (!this._common) this._document.Styles.Add(sectionStyle); else this._document.CommonStyles.Add(sectionStyle); }
/// <summary> /// Creates the footnote. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> /// <returns></returns> public Footnote CreateFootnote(IDocument document,XmlNode node) { try { Footnote fnote = new Footnote(document); fnote.Node = node.CloneNode(true); return fnote; } catch(Exception ex) { throw new AODLException("Exception while trying to create a Footnote.", ex); } }
/// <summary> /// Creates the bookmark. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> /// <param name="type">The type.</param> /// <returns></returns> public Bookmark CreateBookmark(IDocument document,XmlNode node, BookmarkType type) { try { Bookmark bookmark = null; if (type == BookmarkType.Standard) bookmark = new Bookmark(document, BookmarkType.Standard, "noname"); else if (type == BookmarkType.Start) bookmark = new Bookmark(document, BookmarkType.Start, "noname"); else bookmark = new Bookmark(document, BookmarkType.End, "noname"); bookmark.Node = node.CloneNode(true); return bookmark; } catch(Exception ex) { throw new AODLException("Exception while trying to create a Bookmark.", ex); } }
/// <summary> /// Creates the X link. /// </summary> /// <param name="document">The document.</param> /// <param name="node">The node.</param> /// <returns></returns> public XLink CreateXLink(IDocument document, XmlNode node) { try { XLink xlink = new XLink(document); xlink.Node = node.CloneNode(true); ITextCollection iTxtCol = new ITextCollection(); foreach(XmlNode nodeText in xlink.Node.ChildNodes) { IText iText = this.CreateTextObject(xlink.Document, nodeText); if (iText != null) iTxtCol.Add(iText); } xlink.Node.InnerXml = ""; foreach(IText iText in iTxtCol) xlink.TextContent.Add(iText); return xlink; } catch(Exception ex) { throw new AODLException("Exception while trying to create a XLink.", ex); } }
/// <summary> /// Creates a new Node (of the same type as the original node) /// that is similar to the orginal but doesn't contain any /// empty text or CDATA nodes and where all textual content /// including attribute values or comments are trimmed. /// </summary> public static XmlNode StripWhitespace(XmlNode original) { XmlNode cloned = original.CloneNode(true); cloned.Normalize(); HandleWsRec(cloned, false); return cloned; }
private void Copy(XmlNode node) { TreeEditorViewModel.CopiedElement = node.CloneNode(true); }
//Append or override report child node private static void AppendOrOverrideChildNode(XmlNode newFather, XmlNode importChild, string name) { string value = importChild.Attributes[name].Value; bool duplicate = false; XmlNode old = null; foreach (XmlNode xn in newFather.ChildNodes) { if (xn.NodeType != XmlNodeType.Element) continue; if (xn.Name != importChild.Name) continue; if (xn.Attributes[name].Value == value) { duplicate = true; old = xn; break; } } if (duplicate) { newFather.ReplaceChild(importChild.CloneNode(true), old); } else { newFather.AppendChild(importChild.CloneNode(true)); } }
/// <summary> /// Sorts the documents. /// </summary> /// <param name="parentNode">The parent node.</param> public static void SortNodes(ref XmlNode parentNode) { XmlNode n = parentNode.CloneNode(true); // remove all children from original node string xpath = UmbracoSettings.UseLegacyXmlSchema ? "./node" : "./* [@id]"; foreach (XmlNode child in parentNode.SelectNodes(xpath)) parentNode.RemoveChild(child); XPathNavigator nav = n.CreateNavigator(); XPathExpression expr = nav.Compile(xpath); expr.AddSort("@sortOrder", XmlSortOrder.Ascending, XmlCaseOrder.None, "", XmlDataType.Number); XPathNodeIterator iterator = nav.Select(expr); while (iterator.MoveNext()) parentNode.AppendChild( ((IHasXmlNode)iterator.Current).GetNode()); }
public void LogRequest(XmlNode request, bool demo) { request = request.CloneNode(true); MaskXml(SafeFields.MessageType.REQUEST, request, null); string logString = request.OuterXml; if (demo) { Console.WriteLine(DEMO_REQUEST_HEADER + logString + NEWLINE); } Log(LogType.REQUEST, logString ); }
/// <summary> /// Creates the unknown style. /// </summary> /// <param name="styleNode">The style node.</param> private void CreateUnknownStyle(XmlNode styleNode) { if (!this._common) this._document.Styles.Add(new UnknownStyle(this._document, styleNode.CloneNode(true))); else this._document.CommonStyles.Add(new UnknownStyle(this._document, styleNode.CloneNode(true))); }
/// <summary> /// Gets the content. /// </summary> /// <param name="node">The node to clone and create content from.</param> /// <returns></returns> public IContent CreateContent(XmlNode node) { try { switch(node.Name) { case "text:p": return CreateParagraph(node.CloneNode(true)); case "text:list": return CreateList(node.CloneNode(true)); case "text:list-item": return CreateListItem(node.CloneNode(true)); case "table:table": return CreateTable(node.CloneNode(true)); case "table:table-column": return CreateTableColumn(node.CloneNode(true)); case "table:table-row": return CreateTableRow(node.CloneNode(true)); case "table:table-header-rows": return CreateTableHeaderRow(node.CloneNode(true)); case "table:table-cell": return CreateTableCell(node.CloneNode(true)); case "table:covered-table-cell": return CreateTableCellSpan(node.CloneNode(true)); case "text:h": return CreateHeader(node.CloneNode(true)); case "text:table-of-content": //Possible? return CreateTableOfContents(node.CloneNode(true)); case "draw:frame": return CreateFrame(node.CloneNode(true)); case "draw:object": return CreateEmbedObject(node.CloneNode (true)); case "draw:text-box": return CreateDrawTextBox(node.CloneNode(true)); case "draw:image": return CreateGraphic(node.CloneNode(true)); //@Liu Yuhua: What's that??? This is of course a image and not unknown!! Lars //return new UnknownContent(this._document, node.CloneNode(true)); case "draw:area-rectangle": return CreateDrawAreaRectangle(node.CloneNode(true)); case "draw:area-circle": return CreateDrawAreaCircle(node.CloneNode(true)); case "draw:image-map": return CreateImageMap(node.CloneNode(true)); case "office:event-listeners": return CreateEventListeners(node.CloneNode(true)); case "script:event-listener": return CreateEventListeners(node.CloneNode(true)); case "draw:control": return CreateControlRef(node.CloneNode(true)); default: return new UnknownContent(this._document, node.CloneNode(true)); } } catch(Exception ex) { throw new AODLException("Exception while processing a content node.", ex); } }
/// <summary> /// Creates the tab stop style. /// </summary> /// <param name="styleNode">The style node.</param> /// <returns></returns> private TabStopStyle CreateTabStopStyle(XmlNode styleNode) { TabStopStyle tabStopStyle = new TabStopStyle(this._document, styleNode.CloneNode(true)); IPropertyCollection pCollection = new IPropertyCollection(); return tabStopStyle; }
void CopyNode (XmlDocument newDoc, XmlNode from, XmlNode toParent) { if (RemoveAll && from.NodeType != XmlNodeType.Element) return; XmlNode child = null; bool newLineNode = false; switch (from.NodeType) { case XmlNodeType.Element: newLineNode = true; if (RemoveNamespacesAndPrefixes) child = newDoc.CreateElement (from.LocalName); else { XmlElement e = from as XmlElement; child = newDoc.CreateElement (e.Prefix, e.LocalName, e.NamespaceURI); } break; case XmlNodeType.Attribute: { if (RemoveAttributes) return; XmlAttribute fromAttr = from as XmlAttribute; if (!fromAttr.Specified) return; XmlAttribute a; if (RemoveNamespacesAndPrefixes) a = newDoc.CreateAttribute (fromAttr.LocalName); else a = newDoc.CreateAttribute (fromAttr.Prefix, fromAttr.LocalName, fromAttr.NamespaceURI); toParent.Attributes.Append(a); CopyNodes (newDoc, from, a); return; } case XmlNodeType.CDATA: newLineNode = true; child = newDoc.CreateCDataSection ((from as XmlCDataSection).Data); break; case XmlNodeType.Comment: if (RemoveWhiteSpace) return; newLineNode = true; child = newDoc.CreateComment ((from as XmlComment).Data); break; case XmlNodeType.ProcessingInstruction: newLineNode = true; XmlProcessingInstruction pi = from as XmlProcessingInstruction; child = newDoc.CreateProcessingInstruction (pi.Target, pi.Data); break; case XmlNodeType.DocumentType: newLineNode = true; toParent.AppendChild (from.CloneNode (true)); return; case XmlNodeType.EntityReference: child = newDoc.CreateEntityReference ((from as XmlEntityReference).Name); break; case XmlNodeType.SignificantWhitespace: if (RemoveWhiteSpace) return; child = newDoc.CreateSignificantWhitespace (from.Value); break; case XmlNodeType.Text: if (RemoveText) return; newLineNode = true; child = newDoc.CreateTextNode (from.Value); break; case XmlNodeType.Whitespace: if (RemoveWhiteSpace) return; child = newDoc.CreateWhitespace (from.Value); break; case XmlNodeType.XmlDeclaration: newLineNode = true; XmlDeclaration d = from as XmlDeclaration; XmlDeclaration d1 = newDoc.CreateXmlDeclaration (d.Version, d.Encoding, d.Standalone); newDoc.InsertBefore(d1, newDoc.DocumentElement); return; } if (NewLines && newLineNode && toParent.NodeType != XmlNodeType.Attribute) { XmlSignificantWhitespace s = newDoc.CreateSignificantWhitespace("\r\n"); toParent.AppendChild (s); } toParent.AppendChild(child); CopyNodes (newDoc, from, child); }
public void LogReply(XmlNode reply, bool demo) { reply = reply.CloneNode(true); MaskXml(SafeFields.MessageType.REPLY, reply, null); string logString = reply.OuterXml; if (demo) { Console.WriteLine(DEMO_REPLY_HEADER + logString + NEWLINE); } Log(LogType.REPLY, logString ); }
/// <summary> /// Runs a template on the child nodes of an element, and then replaces the element with its children /// </summary> /// <param name="element"></param> /// <param name="templateInput"></param> public void DoTemplate(XmlNode element, object templateInput) { if (templateInput is object[]) { object[] objects = (object[])templateInput; for (int ctr = 0; ctr < objects.Length; ctr++) { object o = objects[ctr]; XmlNode clonedElement = element.CloneNode(true); element.ParentNode.InsertBefore(clonedElement, element); if (o is Dictionary<string, object>) ((Dictionary<string, object>)o)["i"] = ctr; else { Dictionary<string, object> newObject = new Dictionary<string, object>(); newObject["i"] = ctr; newObject[""] = o; o = newObject; } DoTemplate( clonedElement, o); } element.ParentNode.RemoveChild(element); } else { Dictionary<string, object> getParameters = new Dictionary<string, object>(); foreach (XmlAttribute attribute in element.Attributes) if ("" == attribute.NamespaceURI) getParameters["_UP." + attribute.LocalName] = attribute.Value; Flatten(getParameters, "", templateInput); foreach (XmlNode xmlNode in element.ChildNodes) HandleArguments(getParameters, xmlNode); ReplaceNodes(element, element.ChildNodes); } }
private EmbedObject CreateEmbedObject(XmlNode ObjNode) { try { XmlNode ObjectNode = ObjNode.CloneNode (true); XmlNode node = ObjectNode.SelectSingleNode ("@xlink:href",this._document .NamespaceManager ); string ObjectFullPath = node.InnerText.Substring (2)+"/" ; string ObjectRealPath = node.InnerText .Substring (2); string ObjectName =ObjectRealPath; ObjectRealPath = Path.Combine (_document.DirInfo.Dir, ObjectRealPath); string MediaType = GetMediaType(ObjectFullPath); EmbedObjectHandler embedobjhandler = new EmbedObjectHandler (this._document ); return embedobjhandler.CreateEmbedObject (ObjectNode,MediaType,ObjectRealPath,ObjectName); } catch(Exception ex) { throw new AODLException("Exception while trying to create a Graphic.", ex); } }
/// <summary> /// return the deep clone of the given node, in a clone of its document context. /// </summary> /// <param name="node"></param> /// <returns></returns> public static XmlNode CloneNodeWithDocument(XmlNode node) { if (node == null) return null; // get the xpath of the node in its document if (node.NodeType != XmlNodeType.Document) { string xpath = GetXPathInDocument(node); XmlNode clonedOwner = node.OwnerDocument.CloneNode(true); return clonedOwner.SelectSingleNode(xpath); } return node.CloneNode(true); }
private XmlNode TransformTags(XmlDocument xdoc, XmlNode node) { string[] transforms = tagTransforms.Split(';'); XmlNode newNode = null; if (tagTransforms.CompareTo(String.Empty) != 0) { foreach (string transform in transforms) { string[] keys = transform.Split('='); if (node.Name.CompareTo(keys[0]) == 0) { newNode = xdoc.CreateElement(keys[1]); newNode.InnerXml = node.InnerXml; string userTranId = String.Empty; foreach (XmlNode child in node.ChildNodes) { if (child.Name.CompareTo("UserTranId1") == 0 && keys[1].IndexOf("InsertUpdate") > -1) { userTranId = child.InnerText; break; } } if (userTranId.CompareTo(String.Empty) != 0) { XmlNode keyvalueNode = xdoc.CreateElement("KeyValue"); keyvalueNode.InnerText = userTranId; newNode.AppendChild(keyvalueNode); } } } } if (newNode == null) newNode = node.CloneNode(true); return newNode; }
// //createListElement // private static void createListElement( ref System.Xml.XmlDocument pdoc, string pname, string pcore, System.Collections.Generic.List <pvMetadata.ListtemplateContenttype> ptypestable, System.Collections.Generic.List <pvMetadata.ListtemplateColumn> pfieldstable) { // // Insert ContentTypeRef // System.Xml.XmlNode contenttypes = pdoc.SelectSingleNode("//mha:List/mha:MetaData/mha:ContentTypes", s_nsMgr); foreach (ListtemplateContenttype typ in ptypestable) { string ContentTypeID; switch (typ.BasedOn) { case "Element": ContentTypeID = "0x01" + "00" + typ.typeGUID; break; case "Annoncering": ContentTypeID = "0x0104" + "00" + typ.typeGUID; break; case "Hyperlink": ContentTypeID = "0x0105" + "00" + typ.typeGUID; break; case "'Kontaktperson": ContentTypeID = "0x0106" + "00" + typ.typeGUID; break; case "'Meddelelse": ContentTypeID = "0x0107" + "00" + typ.typeGUID; break; case "'Opgave": ContentTypeID = "0x0108" + "00" + typ.typeGUID; break; case "'Problem": ContentTypeID = "0x0103" + "00" + typ.typeGUID; break; default: ContentTypeID = "Error" + "00" + typ.typeGUID; break; } System.Xml.XmlElement contenttyperef = pdoc.CreateElement("", "ContentTypeRef", s_ns); System.Xml.XmlComment contenttypescomment = pdoc.CreateComment(typ.SysName); contenttyperef.SetAttribute("ID", ContentTypeID); System.Xml.XmlNode ContentTypeRef0x01 = pdoc.SelectSingleNode("//mha:List/mha:MetaData/mha:ContentTypes/mha:ContentTypeRef[@ID=\"0x01\"]", s_nsMgr); if (ContentTypeRef0x01 == null) { System.Xml.XmlNode lastContentTypeRef = contenttypes.AppendChild(contenttyperef); contenttypes.InsertBefore(contenttypescomment, lastContentTypeRef); } else { System.Xml.XmlNode Folder = pdoc.SelectSingleNode("//mha:List/mha:MetaData/mha:ContentTypes/mha:ContentTypeRef[@ID=\"0x01\"]/mha:Folder", s_nsMgr); if (Folder != null) { System.Xml.XmlNode copyFolder = Folder.CloneNode(true); contenttyperef.AppendChild(copyFolder); } contenttypes.InsertBefore(contenttypescomment, ContentTypeRef0x01); contenttypes.ReplaceChild(contenttyperef, ContentTypeRef0x01); } } System.Collections.Generic.SortedDictionary <string, ListtemplateColumn> scol = new System.Collections.Generic.SortedDictionary <string, ListtemplateColumn>(); foreach (ListtemplateColumn col in pfieldstable) { scol.Add(col.Seqnr, col); } // // Insert Field in Fields // System.Xml.XmlNode fields = pdoc.SelectSingleNode("//mha:List/mha:MetaData/mha:Fields", s_nsMgr); foreach (ListtemplateColumn col in scol.Values) { if (!col.SysCol) { System.Xml.XmlElement fieldref = pdoc.CreateElement("", "Field", s_ns); fieldref.SetAttribute("Name", col.SysName); fieldref.SetAttribute("ID", col.colGUID); fieldref.SetAttribute("DisplayName", "$Resources:" + pcore + "," + col.SysName + ";"); switch (col.KolonneType) { case "Text": fieldref.SetAttribute("Type", "Text"); break; case "Note": fieldref.SetAttribute("Type", "Note"); fieldref.SetAttribute("NumLines", "3"); fieldref.SetAttribute("RichText", "TRUE"); break; case "Choice": fieldref.SetAttribute("Type", "Choice"); break; case "Number": fieldref.SetAttribute("Type", "Number"); fieldref.SetAttribute("Decimals", "0"); break; case "Percentage": fieldref.SetAttribute("Type", "Number"); fieldref.SetAttribute("Percentage", "TRUE"); fieldref.SetAttribute("Min", "0"); fieldref.SetAttribute("Max", "1"); break; case "Currency": fieldref.SetAttribute("Type", "Currency"); fieldref.SetAttribute("Decimals", "2"); break; case "DateOnly": fieldref.SetAttribute("Type", "DateTime"); fieldref.SetAttribute("Format", "DateOnly"); break; case "DateTime": fieldref.SetAttribute("Type", "DateTime"); break; case "Boolean": fieldref.SetAttribute("Type", "Boolean"); break; case "Counter": fieldref.SetAttribute("Type", "Counter"); break; case "Picture": fieldref.SetAttribute("Type", "Picture"); break; case "Hyperlink": fieldref.SetAttribute("Type", "Hyperlink"); break; default: break; } fields.AppendChild(fieldref); } } // // Insert FieldsRef in ViewFields // System.Xml.XmlNode viewfields = pdoc.SelectSingleNode("//mha:List/mha:MetaData/mha:Views/mha:View[@BaseViewID=\"1\"]/mha:ViewFields", s_nsMgr); foreach (ListtemplateColumn col in scol.Values) { if (!col.SysCol) { System.Xml.XmlElement fieldref = pdoc.CreateElement("", "FieldRef", s_ns); fieldref.SetAttribute("ID", col.colGUID); fieldref.SetAttribute("Name", col.SysName); viewfields.AppendChild(fieldref); } } }
/// <summary> /// Gets the form. /// </summary> /// <param name="formnode">The node of the form.</param> /// <returns></returns> private ODFForm CreateForm(XmlNode formnode) { ODFForm form = null; try { if (formnode.Name == "form:form") { if (this._debugMode) this.LogNode(formnode, "Log form node before"); //Create a new ODFForm ///////////TODO. Fix for child forms! form = new ODFForm(formnode.CloneNode(true), this._document); form.SuppressControlEvents(); foreach(XmlNode nodeChild in form.Node.ChildNodes) { switch (nodeChild.Name) { case "form:form": if (nodeChild.ParentNode==form.Node) { ODFForm frmchild = CreateForm(nodeChild); if (frmchild != null) { form.ChildForms.Add(frmchild); } form.Node.RemoveChild(nodeChild); } break; case "form:properties": break; case "form:button": if (nodeChild.ParentNode==form.Node) { ODFButton button = new ODFButton(form, nodeChild); button.FixPropertyCollection(); form.Controls.Add(button); } break; case "form:listbox": if (nodeChild.ParentNode==form.Node) { ODFListBox listbox = new ODFListBox(form, nodeChild); listbox.FixPropertyCollection(); listbox.FixOptionCollection(); form.Controls.Add(listbox); } break; case "form:combobox": if (nodeChild.ParentNode==form.Node) { ODFComboBox combobox = new ODFComboBox(form, nodeChild); combobox.FixPropertyCollection(); combobox.FixItemCollection(); form.Controls.Add(combobox); } break; case "form:textarea": if (nodeChild.ParentNode==form.Node) { ODFTextArea text = new ODFTextArea(form, nodeChild); text.FixPropertyCollection(); form.Controls.Add(text); } break; case "form:frame": if (nodeChild.ParentNode==form.Node) { ODFFrame frm = new ODFFrame(form, nodeChild); frm.FixPropertyCollection(); form.Controls.Add(frm); } break; case "form:file": if (nodeChild.ParentNode==form.Node) { ODFFile file = new ODFFile(form, nodeChild); file.FixPropertyCollection(); form.Controls.Add(file); } break; case "form:hidden": if (nodeChild.ParentNode==form.Node) { ODFHidden hidden = new ODFHidden(form, nodeChild); hidden.FixPropertyCollection(); form.Controls.Add(hidden); } break; case "form:checkbox": if (nodeChild.ParentNode==form.Node) { ODFCheckBox cb = new ODFCheckBox(form, nodeChild); cb.FixPropertyCollection(); form.Controls.Add(cb); } break; case "form:radio": if (nodeChild.ParentNode==form.Node) { ODFRadioButton rb = new ODFRadioButton(form, nodeChild); rb.FixPropertyCollection(); form.Controls.Add(rb); } break; case "form:formatted-text": if (nodeChild.ParentNode==form.Node) { ODFFormattedText text = new ODFFormattedText(form, nodeChild); text.FixPropertyCollection(); form.Controls.Add(text); } break; case "form:value-range": if (nodeChild.ParentNode==form.Node) { ODFValueRange vr = new ODFValueRange(form, nodeChild); vr.FixPropertyCollection(); form.Controls.Add(vr); } break; case "form:image": if (nodeChild.ParentNode==form.Node) { ODFImage img = new ODFImage(form, nodeChild); img.FixPropertyCollection(); form.Controls.Add(img); } break; case "form:image-frame": if (nodeChild.ParentNode==form.Node) { ODFImageFrame imgf = new ODFImageFrame(form, nodeChild); imgf.FixPropertyCollection(); form.Controls.Add(imgf); } break; case "form:grid": if (nodeChild.ParentNode==form.Node) { ODFGrid gr = new ODFGrid(form, nodeChild); gr.FixPropertyCollection(); gr.FixColumnCollection(); form.Controls.Add(gr); } break; default: if (nodeChild.ParentNode==form.Node) { ODFGenericControl gc = new ODFGenericControl(form, nodeChild); gc.FixPropertyCollection(); form.Controls.Add(gc); } break; } } form.RestoreControlEvents(); form.FixPropertyCollection(); // formnode.RemoveAll(); // formnode.InnerText = ""; } } catch(Exception ex) { throw new AODLException("Exception while processing a form:form node.", ex); } return form; }
/// <summary> /// Decodes the given XML node. The optional "into" argument specifies an /// existing object to be used. If no object is given, then a new /// instance is created using the constructor from the codec. /// The function returns the passed in object or the new instance if no /// object was given. /// </summary> /// <param name="node">XML node to be decoded.</param> /// <param name="into">Optional object to be decodec into.</param> /// <returns>Returns an object that represents the given node.</returns> public Object Decode(XmlNode node, Object into) { Object obj = null; if (node != null && node.NodeType == XmlNodeType.Element) { mxObjectCodec codec = mxCodecRegistry.GetCodec(node.Name); try { if (codec != null) { obj = codec.Decode(this, node, into); } else { obj = node.CloneNode(true); ((XmlElement)obj).RemoveAttribute("as"); } } catch (Exception e) { Console.WriteLine("Cannot decode " + node.Name + ": " + e.Message); } } return obj; }
public static XmlAttributeInstanceMemento CreateMemento(XmlNode node) { var clonedNode = node.CloneNode(true); return new XmlAttributeInstanceMemento(clonedNode); }
public static XmlNode CloneNode(XmlDocument refDocument, XmlNode node, bool deep) { if (node == null) { return null; } bool isOwnerDocument = false; XmlDocument nodeDocument = GetXmlDocument(node, out isOwnerDocument); if ((refDocument == null) || (refDocument == nodeDocument)) { return node.CloneNode(deep); } if (isOwnerDocument) { if (nodeDocument.DocumentElement == null) { return null; } return refDocument.ImportNode(nodeDocument.DocumentElement, deep); } return refDocument.ImportNode(node, deep); }