Example #1
0
        private static IEnumerable <FollowedPath> FollowPath(PSMElement element, FollowedPath followedPath)
        {
            List <FollowedPath> result = new List <FollowedPath>();
            PSMTreeIterator     it     = new PSMTreeIterator(element);

            followedPath.Add(element);
            while (it.CanGoToParent())
            {
                it.GoToParent();
                PSMClass psmClass = it.CurrentNode as PSMClass;
                if (psmClass != null && psmClass.IsReferencedFromStructuralRepresentative())
                {
                    foreach (PSMClass representative in
                             psmClass.Diagram.DiagramElements.Keys.OfType <PSMClass>().Where(rClass => rClass.RepresentedPSMClass == psmClass))
                    {
                        result.AddRange(FollowPath(representative, followedPath.Copy()));
                    }
                }
                followedPath.Add(it.CurrentNode);
            }
            if (followedPath.Last() is PSMClass && ((PSMClass)followedPath.Last()).HasElementLabel)
            {
                result.Add(followedPath);
            }
            return(result);
        }
Example #2
0
            public FollowedPath Copy()
            {
                FollowedPath followedPath = new FollowedPath();

                followedPath.AddRange(this);
                return(followedPath);
            }
Example #3
0
        /// <summary>
        /// Returns all XPath expressions where PSM element can appear in an XML document. Each structural
        /// representative in a diagram can contribute with one expression, where an element can appear.
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static IEnumerable <XPathExpr> PathsWhereElementAppears(PSMElement element)
        {
            List <FollowedPath> result = new List <FollowedPath>();

            FollowedPath followedPath = new FollowedPath();

            result.AddRange(FollowPath(element, followedPath));

            return(from p in result
                   where p.Count > 0 && PSMTreeIterator.IsInSignificantSubtree(p.Last())
                   select p.ToXPath());
        }