} // ParsePblPath // ****************************************************************************** /// <summary> /// Checks if the node addressed by the PBL-Path exists in a NewsML-G2 Package Item /// </summary> /// <param name="pkgItem">The Package Item</param> /// <param name="pblPath">The PBL-Path</param> /// <returns>True if the node exists</returns> public static bool PblNodeExists(PackageItemPwrXml pkgItem, string pblPath) { if (string.IsNullOrEmpty(pblPath)) { return(false); } var pblPathParsed = ParsePblPath(pblPath); if ((pblPathParsed.EndNodeType == PblNodeType.ParseError) || (pblPathParsed.EndNodeType == PblNodeType.Undefined)) { return(false); } // first check for the groups by their roles var groupFound = true; var lastGroupRole = string.Empty; foreach (var groupRole in pblPathParsed.GroupRoles) { lastGroupRole = groupRole; if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + groupRole + "']")) { groupFound = false; } if (!groupFound) { break; } } if (!groupFound) { return(false); } // second: check for itemRef and contentRef - if included into the PBL-Path string[] refIdParts = { "" }; if (!string.IsNullOrEmpty(pblPathParsed.RefId)) { refIdParts = pblPathParsed.RefId.Split('='); // part[0] = attribute name, [1] = value } if (pblPathParsed.EndNodeType == PblNodeType.ItemRef) { if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + lastGroupRole + "']/nar:itemRef[@" + refIdParts[0] + "='" + refIdParts[0] + "']")) { return(false); } } if (pblPathParsed.EndNodeType == PblNodeType.ContentRef) { if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + lastGroupRole + "']/nar:conceptRef[@" + refIdParts[0] + "='" + refIdParts[0] + "']")) { return(false); } } return(true); } // PblNodeExists
// ****************************************************************************** /// <summary> /// Checks if the node addressed by the PBL-Path exists in a NewsML-G2 Package Item /// </summary> /// <param name="pkgItem">The Package Item</param> /// <param name="pblPath">The PBL-Path</param> /// <returns>True if the node exists</returns> public static bool PblNodeExists(PackageItemPwrXml pkgItem, string pblPath) { if (string.IsNullOrEmpty(pblPath)) return false; var pblPathParsed = ParsePblPath(pblPath); if ((pblPathParsed.EndNodeType == PblNodeType.ParseError) || (pblPathParsed.EndNodeType == PblNodeType.Undefined)) return false; // first check for the groups by their roles var groupFound = true; var lastGroupRole = string.Empty; foreach (var groupRole in pblPathParsed.GroupRoles) { lastGroupRole = groupRole; if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + groupRole + "']")) groupFound = false; if (!groupFound) break; } if (!groupFound) return false; // second: check for itemRef and contentRef - if included into the PBL-Path string[] refIdParts = {""}; if (!string.IsNullOrEmpty(pblPathParsed.RefId)) refIdParts = pblPathParsed.RefId.Split('='); // part[0] = attribute name, [1] = value if (pblPathParsed.EndNodeType == PblNodeType.ItemRef) { if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + lastGroupRole + "']/nar:itemRef[@" + refIdParts[0] + "='" + refIdParts[0] + "']")) return false; } if (pblPathParsed.EndNodeType == PblNodeType.ContentRef) { if (!pkgItem.ExistsRelXN("/nar:groupSet/nar:group[@role='" + lastGroupRole + "']/nar:conceptRef[@" + refIdParts[0] + "='" + refIdParts[0] + "']")) return false; } return true; }