Beispiel #1
0
        private static bool Rule02(string name, NodeIndex nodeIndex, XmlNodeList list, ValidationErrorHandler errorHandler)
        {
            bool result = true;

            foreach (XmlElement context in list)
            {
                XmlAttribute href;
                XmlElement   target;

                if (((href = context.GetAttributeNode("href")) == null) ||
                    ((target = nodeIndex.GetElementById(href.Value)) == null))
                {
                    continue;
                }

                string targetName = target.LocalName;

                if (targetName.Equals("creditCurve") ||
                    targetName.Equals("fxCurve") ||
                    targetName.Equals("volatilityRepresentation") ||
                    targetName.Equals("yieldCurve"))
                {
                    continue;
                }

                errorHandler("305", context,
                             "@href must match the @id attribute of an element of type PricingStructure",
                             name, targetName);

                result = false;
            }
            return(result);
        }
        private static bool Rule05(string name, NodeIndex nodeIndex, XmlNodeList list, ValidationErrorHandler errorHandler)
        {
            bool result = true;

            foreach (XmlElement context in list)
            {
                XmlAttribute href;

                if ((context == null) || (href = context.GetAttributeNode("href")) == null)
                {
                    continue;
                }

                XmlElement target = nodeIndex.GetElementById(href.Value);

                if ((target == null) || !target.LocalName.Equals("party"))
                {
                    errorHandler("305", context,
                                 "The @href attribute on the firstPeriodStartDate must reference a party",
                                 name, href.Value);

                    result = false;
                }
            }
            return(result);
        }
        private static bool Rule14A(string name, XmlNodeList list, ValidationErrorHandler errorHandler, NodeIndex nodeIndex)
        {
            bool result = true;

            foreach (XmlElement context in list)
            {
                string href = context.GetAttribute("href");

                if ((href == null) || (href.Length < 2) || (href [0] != '#'))
                {
                    errorHandler("305", context,
                                 "The @href attribute is not a valid XPointer",
                                 name, href);
                    result = false;
                    continue;
                }

                XmlElement referred = nodeIndex.GetElementById(href.Substring(1));

                if ((referred != null) && referred.LocalName.Equals("party"))
                {
                    continue;
                }

                errorHandler("305", context,
                             "Calculation agent party reference '" + context.GetAttribute("href") +
                             "' does not match a party defined in the document.",
                             name, context.GetAttribute("href"));

                result = false;
            }
            return(result);
        }
Beispiel #4
0
        private static bool Rule01(string name, NodeIndex nodeIndex, XmlNodeList list,
                                   ValidationErrorHandler errorHandler)
        {
            bool result = true;

            foreach (XmlElement context in list)
            {
                XmlElement   generic = XPath.Path(context, "generic");
                XmlAttribute href;
                XmlElement   target;

                if ((generic == null) ||
                    ((href = generic.GetAttributeNode("href")) == null) ||
                    ((target = nodeIndex.GetElementById(href.Value)) == null))
                {
                    continue;
                }

                string targetName = target.LocalName;

                if (targetName.Equals("basket") ||
                    targetName.Equals("cash") ||
                    targetName.Equals("commodity") ||
                    targetName.Equals("deposit") ||
                    targetName.Equals("bond") ||
                    targetName.Equals("convertibleBond") ||
                    targetName.Equals("equity") ||
                    targetName.Equals("exchangeTradedFund") ||
                    targetName.Equals("index") ||
                    targetName.Equals("future") ||
                    targetName.Equals("fxRate") ||
                    targetName.Equals("loan") ||
                    targetName.Equals("mortgage") ||
                    targetName.Equals("mutualFund") ||
                    targetName.Equals("rateIndex") ||
                    targetName.Equals("simpleCreditDefautSwap") ||
                    targetName.Equals("simpleFra") ||
                    targetName.Equals("simpleIrSwap") ||
                    targetName.Equals("dealSummary") ||
                    targetName.Equals("facilitySummary"))
                {
                    continue;
                }

                errorHandler("305", context,
                             "generic/@href must match the @id attribute of an element of type Asset",
                             name, targetName);

                result = false;
            }
            return(result);
        }
        //---------------------------------------------------------------------

        private static bool Rule17(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool result = true;

            foreach (XmlElement context in XPath.Paths(nodeIndex.GetElementsByName("tradeSide"), "*", "account"))
            {
                string     href   = context.GetAttribute("href");
                XmlElement target = nodeIndex.GetElementById(href);

                if (target.LocalName.Equals("account"))
                {
                    continue;
                }

                errorHandler("305", context,
                             "The value of the href attribute does not refer to an account structure",
                             name, href);

                result = false;
            }
            return(result);
        }
        private static bool Rule13B(string name, XmlNodeList list, ValidationErrorHandler errorHandler, NodeIndex nodeIndex)
        {
            bool result = true;

            foreach (XmlElement context in list)
            {
                string     href     = context.GetAttribute("href");
                XmlElement referred = nodeIndex.GetElementById(href);

                if ((referred != null) && (referred.LocalName.Equals("party") || referred.LocalName.Equals("tradeSide")))
                {
                    continue;
                }

                errorHandler("305", context,
                             "Seller party reference '" + context.GetAttribute("href") +
                             "' does not match a party defined in the document.",
                             name, context.GetAttribute("href"));

                result = false;
            }
            return(result);
        }