Example #1
0
        private bool LoadLocator(XmlNode locNode,
                                 Dictionary <string, string> discoveredSchemas, string schemaPath)
        {
            string href  = null;
            string label = null;

            if (!Common.GetAttribute(locNode, HREF_TAG, ref href, errorList) ||
                !Common.GetAttribute(locNode, LABEL_TAG, ref label, errorList))
            {
                return(false);
            }

            if (string.IsNullOrEmpty(href))
            {
                return(false);
            }

            LocatorBase locator = CreateLocator(href);

            locator.ParseHRef(errorList);
            LinkBase.AddDiscoveredSchema(schemaPath, locator.Xsd, discoveredSchemas);


            locator.AddLabel(label);


            if (locators.ContainsKey(locator.HRef))
            {
                PresentationLocator oll = (PresentationLocator)locators[locator.HRef];


                // add a new one, pointing to the same locator
                if (!oll.LabelArray.Contains(label))
                {
                    oll.AddLabel(label);
                }
            }
            else
            {
                locators[locator.HRef] = locator;
            }

            HybridDictionary hrefList = this.LabelHrefMapping[label] as HybridDictionary;

            if (hrefList == null)
            {
                hrefList = new HybridDictionary();
                this.LabelHrefMapping[label] = hrefList;
            }

            hrefList[locator.HRef] = 1;

            return(true);
        }
Example #2
0
        public void LoadRoleRefs(Dictionary <string, string> discoveredSchemas, out int numErrors)
        {
            numErrors = 0;

            XmlNodeList rolesList = theDocument.SelectNodes(RREF_KEY, theManager);

            if (rolesList == null)
            {
                return;
            }


            foreach (XmlNode role in rolesList)
            {
                if (roleRefs == null)
                {
                    roleRefs = new Hashtable();
                }
                string uri  = string.Empty;
                string href = string.Empty;

                if (!Common.GetAttribute(role, HREF_TAG, ref href, errorList) ||
                    !Common.GetAttribute(role, RURI_TAG, ref uri, errorList))
                {
                    ++numErrors;
                    continue;
                }

                RoleRef rr = new RoleRef(href, uri);
                roleRefs[uri] = rr;


                string xsdName = rr.GetSchemaName();
                LinkBase.AddDiscoveredSchema(this.schemaPath, xsdName, discoveredSchemas);
            }
        }