public GetAttributeValue ( byte attrWithEquals ) : string | ||
attrWithEquals | byte | The attribute name with a leading space and a trailing =. |
return | string |
private static HashSet <string> GetOwnees(byte[] xmlBytes) { var ownees = new HashSet <string>(); var ichEnd = xmlBytes.Length; var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur); while (objsurBounds.IsValid) { var type = objsurBounds.GetAttributeValue(s_tAttr); if (type == "o") { var guid = objsurBounds.GetAttributeValue(s_guidAttr); if (!String.IsNullOrEmpty(guid)) { ownees.Add(guid.ToLowerInvariant()); } } objsurBounds.Reset(objsurBounds.EndTagOffset, ichEnd); } return(ownees); }
private static HashSet<string> GetOwnees(byte[] xmlBytes) { var ownees = new HashSet<string>(); var ichEnd = xmlBytes.Length; var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur); while (objsurBounds.IsValid) { var type = objsurBounds.GetAttributeValue(s_tAttr); if (type == "o") { var guid = objsurBounds.GetAttributeValue(s_guidAttr); if (!String.IsNullOrEmpty(guid)) ownees.Add(guid.ToLowerInvariant()); } objsurBounds.Reset(objsurBounds.EndTagOffset, ichEnd); } return ownees; }
private static void DeleteCcwgWithGuidIndex(IDomainObjectDTORepository dtoRepos) { const int kLongIntLength = 10; var goners = new List<DomainObjectDTO>(); var ccwgs = dtoRepos.AllInstancesSansSubclasses("ConstChartWordGroup"); foreach (var dto in ccwgs) { int dummy; var ebBegIndex = new ElementBounds(dto.XmlBytes, s_tagsBegAnalysisIndex); var ebEndIndex = new ElementBounds(dto.XmlBytes, s_tagsEndAnalysisIndex); if (!(ebBegIndex.IsValid && ebEndIndex.IsValid)) continue; // Hopefully this isn't a problem! var sBegAnalysisIndexValue = ebBegIndex.GetAttributeValue(s_valAttr); var sEndAnalysisIndexValue = ebEndIndex.GetAttributeValue(s_valAttr); if (!Int32.TryParse(sBegAnalysisIndexValue, out dummy) || !Int32.TryParse(sEndAnalysisIndexValue, out dummy)) { // Found something that needs fixing! // There's likely a guid instead of an integer, due to an unresolved // reference where the wfic it used to refer to has been deleted // for some (valid) reason. goners.Add(dto); continue; } } // need to remove goners from dtoRepos and make sure that empty rows get deleted too. if (goners.Count > 0) { var neededGoners = new Set<string>(); DeleteUnneededGoners(dtoRepos, goners, neededGoners); goners.Clear(); } }
internal static int GetEndOffset(byte[] xmlBytes) { var baseBounds = new ElementBounds(xmlBytes, s_tagsCmBaseAnnotation); if (!baseBounds.IsValid) return 0; var offsetBounds = new ElementBounds(xmlBytes, s_tagsEndOffset, baseBounds.BeginTagOffset, baseBounds.EndTagOffset); if (!offsetBounds.IsValid) return 0; var val = offsetBounds.GetAttributeValue(s_valAttr); return String.IsNullOrEmpty(val) ? 0 : int.Parse(val); }
private static void MarkParaAsNeedingTokenization(IDomainObjectDTORepository dtoRepos, DomainObjectDTO paraDto) { var stTxtParaBounds = new ElementBounds(paraDto.XmlBytes, s_tagsStTxtPara); if (!stTxtParaBounds.IsValid) return; // should never happen! var parseIsCurrentBounds = new ElementBounds(paraDto.XmlBytes, s_tagsParseIsCurrent, stTxtParaBounds.BeginTagOffset, stTxtParaBounds.EndTagOffset); List<byte> newXml; int ichInsert; if (parseIsCurrentBounds.IsValid) { var val = parseIsCurrentBounds.GetAttributeValue(s_valAttr); if (val.ToLowerInvariant() != "true") return; newXml = new List<byte>(paraDto.XmlBytes.Length + 5); newXml.AddRange(paraDto.XmlBytes); newXml.RemoveRange(parseIsCurrentBounds.BeginTagOffset, parseIsCurrentBounds.Length); ichInsert = parseIsCurrentBounds.BeginTagOffset; } else { newXml = new List<byte>(paraDto.XmlBytes.Length + 40); newXml.AddRange(paraDto.XmlBytes); ichInsert = stTxtParaBounds.EndTagOffset; } newXml.InsertRange(ichInsert, Encoding.UTF8.GetBytes("<ParseIsCurrent val=\"False\"/>")); // Tell DTO repos about the modification to the para. DataMigrationServices.UpdateDTO(dtoRepos, paraDto, newXml.ToArray()); }
private static void RemoveMismatchedAppliesToRefs(byte[] xmlBytes, ICollection<string> appliesToGuids) { var cmIndirectBounds = new ElementBounds(xmlBytes, s_tagsCmIndirect); if (!cmIndirectBounds.IsValid) return; var appliesToBounds = new ElementBounds(xmlBytes, s_tagsAppliesTo, cmIndirectBounds.BeginTagOffset, cmIndirectBounds.EndTagOffset); if (!appliesToBounds.IsValid) return; var objsurBounds = new ElementBounds(xmlBytes, s_tagsObjsur, appliesToBounds.BeginTagOffset, appliesToBounds.EndTagOffset); while (objsurBounds.IsValid) { var ichMin = objsurBounds.BeginTagOffset; var guid = objsurBounds.GetAttributeValue(s_guidAttr); if (!String.IsNullOrEmpty(guid)) guid = guid.ToLowerInvariant(); objsurBounds.Reset(objsurBounds.EndTagOffset, appliesToBounds.EndTagOffset); if (!String.IsNullOrEmpty(guid) && !appliesToGuids.Contains(guid)) { var ichLim = objsurBounds.BeginTagOffset; if (ichLim < 0) ichLim = appliesToBounds.EndTagOffset; // Remove the <objsur> element by overwriting it with spaces. for (var i = ichMin; i < ichLim; ++i) xmlBytes[i] = 0x20; } } }
private static List<string> GetParagraphContentRuns(byte[] xmlStTxtPara, out List<string> writingSystems) { var retval = new List<string>(); writingSystems = new List<string>(); var stTxtParaBounds = new ElementBounds(xmlStTxtPara, s_tagsStTxtPara); var contentsBounds = new ElementBounds(xmlStTxtPara, s_tagsContents, stTxtParaBounds.BeginTagOffset, stTxtParaBounds.EndTagOffset); var strBounds = new ElementBounds(xmlStTxtPara, s_tagsStr, contentsBounds.BeginTagOffset, contentsBounds.EndTagOffset); if (!strBounds.IsValid) return retval; var runBounds = new ElementBounds(xmlStTxtPara, s_tagsRun, strBounds.BeginTagOffset, strBounds.EndTagOffset); while (runBounds.IsValid) { var ws = runBounds.GetAttributeValue(s_wsAttr); writingSystems.Add(ws); var ichText = runBounds.EndOfStartTag + 1; // move past the > var runText = Encoding.UTF8.GetString(xmlStTxtPara, ichText, runBounds.EndTagOffset - ichText); retval.Add(XmlUtils.DecodeXmlAttribute(runText)); runBounds.Reset(runBounds.EndTagOffset, contentsBounds.EndTagOffset); } return retval; }
private static ElementBounds GetEnglishCommentBounds(byte[] xmlBytes, int ichMin, int ichLim) { var commentBounds = new ElementBounds(xmlBytes, s_tagsComment, ichMin, ichLim); if (!commentBounds.IsValid) return null; var astrBounds = new ElementBounds(xmlBytes, s_tagsAStr, commentBounds.BeginTagOffset, commentBounds.EndTagOffset); while (astrBounds.IsValid) { var ws = astrBounds.GetAttributeValue(s_wsAttr); if (ws == "en") return astrBounds; astrBounds.Reset(astrBounds.EndTagOffset, commentBounds.EndTagOffset); } return null; }