private void WriteDom(XfdfObject xfdfObject) { XmlDocument document = XfdfFileUtils.CreateNewXfdfDocument(); // root xfdf element XmlElement root = document.CreateElement("xfdf"); document.AppendChild(root); //write fields if (xfdfObject.GetFields() != null && xfdfObject.GetFields().GetFieldList() != null && !xfdfObject.GetFields ().GetFieldList().IsEmpty()) { XmlElement fields = document.CreateElement("fields"); root.AppendChild(fields); IList <FieldObject> fieldList = xfdfObject.GetFields().GetFieldList(); foreach (FieldObject fieldObject in fieldList) { if (fieldObject.GetParent() == null) { AddField(fieldObject, fields, document, fieldList); } } } //write annots if (xfdfObject.GetAnnots() != null && xfdfObject.GetAnnots().GetAnnotsList() != null && !xfdfObject.GetAnnots ().GetAnnotsList().IsEmpty()) { XmlElement annots = document.CreateElement("annots"); root.AppendChild(annots); foreach (AnnotObject annotObject in xfdfObject.GetAnnots().GetAnnotsList()) { AddAnnot(annotObject, annots, document); } } //write f if (xfdfObject.GetF() != null) { XmlElement f = document.CreateElement("f"); AddFAttributes(xfdfObject.GetF(), f); root.AppendChild(f); } //write ids if (xfdfObject.GetIds() != null) { XmlElement ids = document.CreateElement("ids"); AddIdsAttributes(xfdfObject.GetIds(), ids); root.AppendChild(ids); } // create the xml file //transform the DOM Object to an XML File XfdfFileUtils.SaveXfdfDocumentToFile(document, this.outputStream); }
public virtual void FieldNullValueUnitTest() { XmlDocument document = XfdfFileUtils.CreateNewXfdfDocument(); XmlElement fields = document.CreateElement("fields"); document.AppendChild(fields); FieldObject fieldObject = new FieldObject(); fieldObject.SetName("testname"); IList <FieldObject> fieldList = new List <FieldObject>(); XfdfWriter.AddField(fieldObject, fields, document, fieldList); XmlNode childOfFields = fields.FirstChild; NUnit.Framework.Assert.IsNotNull(childOfFields); NUnit.Framework.Assert.IsNull(childOfFields.FirstChild); }