// ****************************************************************************** /// <summary> /// Appends this object as concept element as child to a parent element /// </summary> /// <param name="NG2Item">The NewsML-G2 item</param> /// <param name="parentXPath">XPath of the parent element</param> /// <returns>A Property Processing Statuts</returns> public virtual PropProcStatus AppendAsChildOf(AnyItemXml NG2Item, string parentXPath) // Code History: // 2014-02-27 mws { if (string.IsNullOrEmpty(parentXPath)) { return(PropProcStatus.ErrNoXPath); } XmlNodeList parentXNL = NG2Item.XmlDoc.SelectNodes(parentXPath, NG2Item.NsMngr); if (parentXNL.Count == 0) { return(PropProcStatus.ErrElementNotFound); } if (parentXNL.Count > 1) { return(PropProcStatus.ErrElementsToManyFound); } XmlElement cptElement = NG2Item.XmlDoc.CreateElement("concept", NarDocXml.G2NsCs); parentXNL[0].AppendChild(cptElement); return(ApplyToElementInternal(NG2Item, cptElement, true)); } // AppendAsChildOf
// ****************************************************************************** protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) // Code History: // 2014-02-27 mws { var baseResult = base.ApplyToElementInternal(NG2Item, applyElement, fullConceptMode); if (baseResult != PropProcStatus.ok) { return(baseResult); } foreach (var personDetails in PersonDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("personDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(personDetails, newElement); applyElement.AppendChild(newElement); } foreach (var organisationDetails in OrganisationDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("organisationDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(organisationDetails, newElement); applyElement.AppendChild(newElement); } foreach (var geoAreaDetails in GeoAreaDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("geoAreaDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(geoAreaDetails, newElement); applyElement.AppendChild(newElement); } foreach (var poiDetails in PoiDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("POIDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(poiDetails, newElement); applyElement.AppendChild(newElement); } foreach (var objectDetails in ObjectDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("objectDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(objectDetails, newElement); applyElement.AppendChild(newElement); } return(PropProcStatus.ok); }
// ****************************************************************************** protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) // Code History: // 2014-02-27 mws { var baseResult = base.ApplyToElementInternal(NG2Item, applyElement, fullConceptMode); if (baseResult != PropProcStatus.ok) { return(baseResult); } foreach (var eventDetails in EventDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("eventDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(eventDetails, newElement); applyElement.AppendChild(newElement); } return(PropProcStatus.ok); }
// Code History: // 2014-02-27 mws // ****************************************************************************** protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) { var baseResult = base.ApplyToElementInternal(NG2Item, applyElement, fullConceptMode); if (baseResult != PropProcStatus.ok) return baseResult; foreach (var personDetails in PersonDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("personDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(personDetails, newElement); applyElement.AppendChild(newElement); } foreach (var organisationDetails in OrganisationDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("organisationDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(organisationDetails, newElement); applyElement.AppendChild(newElement); } foreach (var geoAreaDetails in GeoAreaDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("geoAreaDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(geoAreaDetails, newElement); applyElement.AppendChild(newElement); } foreach (var poiDetails in PoiDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("POIDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(poiDetails, newElement); applyElement.AppendChild(newElement); } foreach (var objectDetails in ObjectDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("objectDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(objectDetails, newElement); applyElement.AppendChild(newElement); } return PropProcStatus.ok; }
// Code History: // 2014-02-27 mws // ****************************************************************************** /// <summary> /// Internal method for applying the object to an XML Element /// </summary> /// <param name="NG2Item">The NewsML-G2 Item</param> /// <param name="applyElement">The XML Element to which the object should be applied</param> /// <param name="fullConceptMode">If true: treat the applyElement as concept element, else: treat it as any other property having a concept as value</param> /// <returns>A Property Processing Statuts</returns> protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) { NG2Item.NarProperty2XmlElement(CoreConcept, applyElement); if (fullConceptMode) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("conceptId", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(ConceptId, newElement); applyElement.AppendChild(newElement); newElement = NG2Item.XmlDoc.CreateElement("type", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(Type, newElement); applyElement.AppendChild(newElement); } else { if (!string.IsNullOrEmpty(ConceptId.qcode)) { applyElement.SetAttribute("qcode", ConceptId.qcode); } else { if (!string.IsNullOrEmpty(QCode)) applyElement.SetAttribute("qcode", QCode); } if (!string.IsNullOrEmpty(ConceptId.uri)) { applyElement.SetAttribute("uri", ConceptId.uri); } else { if (!string.IsNullOrEmpty(Uri)) applyElement.SetAttribute("uri", Uri); } if (!string.IsNullOrEmpty(Type.qcode)) { applyElement.SetAttribute("type", Type.qcode); } else { if (!string.IsNullOrEmpty(TypeQc)) applyElement.SetAttribute("type", TypeQc); } } foreach (var name in Names) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("name", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(name, newElement); applyElement.AppendChild(newElement); } foreach (var definition in Definitions) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("definition", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(definition, newElement); applyElement.AppendChild(newElement); } foreach (var note in Notes) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("note", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(note, newElement); applyElement.AppendChild(newElement); } foreach (var remoteInfo in RemoteInfos) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("remoteInfo", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(remoteInfo, newElement); applyElement.AppendChild(newElement); } foreach (var hierarchyInfo in HierarchyInfos) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("hierarchyInfo", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(hierarchyInfo, newElement); applyElement.AppendChild(newElement); } foreach (var sameAs in SameAsses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("sameAs", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(sameAs, newElement); applyElement.AppendChild(newElement); } foreach (var broader in Broaders) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("broader", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(broader, newElement); applyElement.AppendChild(newElement); } foreach (var narrower in Narrowers) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("narrower", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(narrower, newElement); applyElement.AppendChild(newElement); } foreach (var related in Relateds) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("related", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(related, newElement); applyElement.AppendChild(newElement); } return PropProcStatus.ok; }
/// <summary> /// Applies all attributes and child elements of this object to an existing XML element /// </summary> /// <param name="NG2Item">The NewsML-G2 item</param> /// <param name="applyElement">The XML Element to which the object should be applied</param> /// <returns>A Property Processing Statuts</returns> public PropProcStatus ApplyToElement(AnyItemXml NG2Item, XmlElement applyElement) { return ApplyToElementInternal(NG2Item, applyElement, false); }
// Code History: // 2014-02-27 mws // ****************************************************************************** /// <summary> /// Appends this object as concept element as child to a parent element /// </summary> /// <param name="NG2Item">The NewsML-G2 item</param> /// <param name="parentXPath">XPath of the parent element</param> /// <returns>A Property Processing Statuts</returns> public virtual PropProcStatus AppendAsChildOf(AnyItemXml NG2Item, string parentXPath) { if (string.IsNullOrEmpty(parentXPath)) return PropProcStatus.ErrNoXPath; XmlNodeList parentXNL = NG2Item.XmlDoc.SelectNodes(parentXPath, NG2Item.NsMngr); if (parentXNL.Count == 0) return PropProcStatus.ErrElementNotFound; if (parentXNL.Count > 1) return PropProcStatus.ErrElementsToManyFound; XmlElement cptElement = NG2Item.XmlDoc.CreateElement("concept", NarDocXml.G2NsCs); parentXNL[0].AppendChild(cptElement); return ApplyToElementInternal(NG2Item, cptElement, true); }
// Code History: // 2014-02-27 mws // ****************************************************************************** protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) { var baseResult = base.ApplyToElementInternal(NG2Item, applyElement, fullConceptMode); if (baseResult != PropProcStatus.ok) return baseResult; foreach (var eventDetails in EventDetailses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("eventDetails", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(eventDetails, newElement); applyElement.AppendChild(newElement); } return PropProcStatus.ok; }
// ****************************************************************************** /// <summary> /// Internal method for applying the object to an XML Element /// </summary> /// <param name="NG2Item">The NewsML-G2 Item</param> /// <param name="applyElement">The XML Element to which the object should be applied</param> /// <param name="fullConceptMode">If true: treat the applyElement as concept element, else: treat it as any other property having a concept as value</param> /// <returns>A Property Processing Statuts</returns> protected virtual PropProcStatus ApplyToElementInternal(AnyItemXml NG2Item, XmlElement applyElement, bool fullConceptMode) // Code History: // 2014-02-27 mws { NG2Item.NarProperty2XmlElement(CoreConcept, applyElement); if (fullConceptMode) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("conceptId", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(ConceptId, newElement); applyElement.AppendChild(newElement); newElement = NG2Item.XmlDoc.CreateElement("type", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(Type, newElement); applyElement.AppendChild(newElement); } else { if (!string.IsNullOrEmpty(ConceptId.qcode)) { applyElement.SetAttribute("qcode", ConceptId.qcode); } else { if (!string.IsNullOrEmpty(QCode)) { applyElement.SetAttribute("qcode", QCode); } } if (!string.IsNullOrEmpty(ConceptId.uri)) { applyElement.SetAttribute("uri", ConceptId.uri); } else { if (!string.IsNullOrEmpty(Uri)) { applyElement.SetAttribute("uri", Uri); } } if (!string.IsNullOrEmpty(Type.qcode)) { applyElement.SetAttribute("type", Type.qcode); } else { if (!string.IsNullOrEmpty(TypeQc)) { applyElement.SetAttribute("type", TypeQc); } } } foreach (var name in Names) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("name", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(name, newElement); applyElement.AppendChild(newElement); } foreach (var definition in Definitions) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("definition", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(definition, newElement); applyElement.AppendChild(newElement); } foreach (var note in Notes) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("note", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(note, newElement); applyElement.AppendChild(newElement); } foreach (var remoteInfo in RemoteInfos) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("remoteInfo", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(remoteInfo, newElement); applyElement.AppendChild(newElement); } foreach (var hierarchyInfo in HierarchyInfos) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("hierarchyInfo", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(hierarchyInfo, newElement); applyElement.AppendChild(newElement); } foreach (var sameAs in SameAsses) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("sameAs", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(sameAs, newElement); applyElement.AppendChild(newElement); } foreach (var broader in Broaders) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("broader", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(broader, newElement); applyElement.AppendChild(newElement); } foreach (var narrower in Narrowers) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("narrower", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(narrower, newElement); applyElement.AppendChild(newElement); } foreach (var related in Relateds) { XmlElement newElement = NG2Item.XmlDoc.CreateElement("related", NarDocXml.G2NsCs); NG2Item.NarProperty2XmlElement(related, newElement); applyElement.AppendChild(newElement); } return(PropProcStatus.ok); } // ApplyToElement
} // AppendAsChildOf /// <summary> /// Applies all attributes and child elements of this object to an existing XML element /// </summary> /// <param name="NG2Item">The NewsML-G2 item</param> /// <param name="applyElement">The XML Element to which the object should be applied</param> /// <returns>A Property Processing Statuts</returns> public PropProcStatus ApplyToElement(AnyItemXml NG2Item, XmlElement applyElement) { return(ApplyToElementInternal(NG2Item, applyElement, false)); }