/// <summary> /// Converts path <paramref name="oldPath"/> /// into a path relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ProcessedPath"/>. /// (and also relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ContentGroupPath"/> if it is used). /// </summary> /// <param name="context">current generator context</param> /// <param name="oldPath">projected path</param> /// <returns>relative xpath expression</returns> public static XPathExpr GroupAwareProjectXPathWithoutAttributeCorrection(XsltGeneratorContext context, XPathExpr oldPath) { if (context.InGroup && oldPath.HasPrefix(context.ContentGroupPath)) { oldPath = oldPath.InsertAfterPrefix(context.ContentGroupPath, "/$cg"); } XPathExpr tmp = ProjectXPath(context.ProcessedPath, oldPath, context.InGroup); return(tmp); }
internal XPathExpr NodeToProcessedPath(PSMElement node) { Version oldVersion = ChangeSet.OldVersion; if (!InGroup) { return(XPathHelper.GetXPathForNode(node, oldVersion)); } else { XPathExpr path = XPathHelper.GetXPathForNode(node, oldVersion).Append("/$cg"); //if (InGroup/* && ProcessedPath.HasPrefix(ContentGroupPath)*/) { Debug.Assert(path.HasPrefix(ContentGroupPath)); Debug.Assert(path == (!ContentGroupPath.ToString().EndsWith("/$cg") ? ContentGroupPath.Append("/$cg") : ContentGroupPath)); //path = path.InsertAfterPrefix(ContentGroupPath, "/$cg"); } return(path); } }
/// <summary> /// Converts path to <paramref name="psmElementNewVersion"/> /// into a path relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ProcessedPath"/>. /// (and also relative to <paramref name="context"/>.<see cref="XsltGeneratorContext.ContentGroupPath"/> if it is used). /// If context is in group (<see cref="XsltGeneratorContext"/>.<see cref="XsltGeneratorContext.InGroup"/>) which /// has group attributes and <paramref name="psmElementNewVersion"/> is one of these attributes, the returned path /// is modified to use the '$attributes' variable. /// </summary> /// <param name="context">current generator context</param> /// <param name="psmElementNewVersion">element for which the path is projected</param> /// <param name="oldVersion">old version, used to determine the path to <paramref name="psmElementNewVersion"/> in the /// old version of the diagram</param> /// <returns>relative xpath expression</returns> public static XPathExpr GroupAwareProjectXPath(XsltGeneratorContext context, PSMElement psmElementNewVersion, Version oldVersion) { XPathExpr oldPath = ((PSMElement)psmElementNewVersion.GetInVersion(oldVersion)).XPathE(); if (context.InGroup && oldPath.HasPrefix(context.ContentGroupPath)) { oldPath = oldPath.InsertAfterPrefix(context.ContentGroupPath, "/$cg"); } XPathExpr tmp = ProjectXPath(context.ProcessedPath, oldPath, context.InGroup); if (context.InGroup && context.ContentGroupAttributes != null && psmElementNewVersion is PSMAttribute && context.ContentGroupAttributes.Contains((PSMAttribute)psmElementNewVersion)) { if (tmp.ToString().StartsWith(XPathExpr.CurrentGroupVariableExpr)) { tmp = new XPathExpr(tmp.ToString().Replace(XPathExpr.CurrentGroupVariableExpr, "$attributes")); } } return(tmp); }