GetElementsByName() public method

Creates a (possibly empty) XmlNodeList containing all the element nodes identified by the given name string.
public GetElementsByName ( string name ) : XmlNodeList
name string The name of the required elements.
return System.Xml.XmlNodeList
        /// <summary>
        /// Evaluates this <see cref="Precondition"/> against the contents of the
        /// indicated <see cref="NodeIndex"/>.
        /// </summary>
        /// <param name="nodeIndex">The <see cref="NodeIndex"/> of a <see cref="XmlDocument"/>.</param>
        /// <param name="cache">A cache of previously evaluated precondition results.</param>
        /// <returns>A <see cref="bool"/> value indicating the applicability of this
        /// <see cref="Precondition"/> to the <see cref="XmlDocument"/>.</returns>
        public override bool Evaluate(NodeIndex nodeIndex, Dictionary<Precondition, bool> cache)
        {
            foreach (string rootElement in release.RootElements) {
                XmlNodeList list = nodeIndex.GetElementsByName (rootElement);

                if (list.Count == 1) {
                    XmlElement	fpml = list [0] as XmlElement;

                    if (fpml.LocalName.Equals("FpML"))
                        return (fpml.GetAttribute ("version").Equals (release.Version));
                    else
                        return (fpml.GetAttribute ("fpmlVersion").Equals (release.Version));
                }
            }
            return (false);
        }
Ejemplo n.º 2
0
        //---------------------------------------------------------------------
        private static bool Rule09(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result = true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("cashSettlementPaymentDate"))
                result &= Rule09 (name, context.GetElementsByTagName ("businessDateRange"), errorHandler);

            return (result);
        }
        // --------------------------------------------------------------------
        private static bool Rule02(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule02 (name, nodeIndex, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "PaymentCalculationPeriod"), errorHandler));

            return (Rule02 (name, nodeIndex, nodeIndex.GetElementsByName ("paymentCalculationPeriod"), errorHandler));
        }
Ejemplo n.º 4
0
        // --------------------------------------------------------------------
        private static bool Rule14(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                foreach (XmlElement seller in XPath.Paths (context, "protectionTerms", "creditEvents", "creditEventNotice", "notifyingParty", "sellerPartyReference")) {
                    if (Equal (seller.GetAttribute ("href"),
                            XPath.Path (context, "generalTerms", "sellerPartyReference").GetAttribute ("href")))
                        continue;

                    errorHandler ("305", context,
                        "If protectionTerms/creditEvents/creditEventNotice/notifyingParty/sellerPartyReference " +
                        "is present, its @href attribute must match that of generalTerms/sellerPartyReference",
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 5
0
        // --------------------------------------------------------------------
        private static bool Rule12(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("referenceInformation")) {
                if (Exists (context ["referencePrice"])) {
                    if (GreaterOrEqual (context ["referencePrice"], 0.0))
                        continue;

                    errorHandler ("305", context,
                        "If referencePrice is present it must not have a negative " +
                        "value",
                        name, context ["referencePrice"].InnerText);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 6
0
        // --------------------------------------------------------------------
        private static bool Rule10(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("referenceInformation")) {
                string			primaryReference;
                string			primaryId;

                foreach (XmlElement primary in XPath.Paths (context, "referenceObligation", "guarantorReference")) {
                    if (Equal (
                            primaryReference = primary.GetAttribute ("href"),
                            primaryId		 = context ["referenceEntity"].GetAttribute ("id")))
                        continue;

                    errorHandler ("305", context,
                        "Primary obligor reference '" + primaryReference +
                        "' should point to the reference entity ' " + primaryId + "'",
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 7
0
        // --------------------------------------------------------------------
        private static bool Rule06(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("generalTerms")) {
                XmlElement  buyer   = context ["buyerPartyReference"];
                XmlElement  seller  = context ["sellerPartyReference"];

                if ((buyer == null) || (seller == null) ||
                    NotEqual (buyer.GetAttribute ("href"), seller.GetAttribute ("href")))
                    continue;

                errorHandler ("305", context,
                    "Buyer party reference is equal to seller party reference",
                    name, seller.GetAttribute ("href"));

                result = false;
            }
            return (result);
        }
Ejemplo n.º 8
0
 // --------------------------------------------------------------------
 private static bool Rule44(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule44 (name, nodeIndex.GetElementsByName ("creditDefaultSwap"), errorHandler));
 }
Ejemplo n.º 9
0
        // --------------------------------------------------------------------
        private static bool Rule28(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result = true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                XmlElement	paymentDate;
                XmlElement	effectiveDate;

                if (Implies (
                    Exists (XPath.Path (context, "feeLeg", "periodicPayment", "firstPaymentDate")),
                    Greater (
                        paymentDate = XPath.Path (context, "feeLeg", "periodicPayment", "firstPaymentDate"),
                        effectiveDate = XPath.Path (context, "generalTerms", "effectiveDate", "unadjustedDate"))))
                    continue;

                errorHandler ("305", context,
                    "First periodic payment date '" + paymentDate.InnerText + "' " +
                    "must be after the effective date '" + effectiveDate.InnerText + "'",
                    name, null);

                result = false;
            }
            return (result);
        }
Ejemplo n.º 10
0
        //---------------------------------------------------------------------
        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);
        }
Ejemplo n.º 11
0
 //---------------------------------------------------------------------
 private static bool Rule15(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (
         Rule15 (name, nodeIndex.GetElementsByName ("gracePeriod"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("paymentDaysOffset"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("rateCutOffDaysOffset"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("relativeDate"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("fixingDateOffset"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("initialFixingDate"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("fixingDates"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("cashSettlementValuationDate"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("varyingNotionalInterimExchangePaymentDates"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("varyingNotionalFixingDates"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("feePaymentDate"), errorHandler)
         & Rule15 (name, nodeIndex.GetElementsByName ("relativeDates"), errorHandler));
 }
Ejemplo n.º 12
0
 //---------------------------------------------------------------------
 private static bool Rule14B(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule14B (name, nodeIndex.GetElementsByName ("calculationAgentPartyReference"), errorHandler, nodeIndex));
 }
Ejemplo n.º 13
0
 //---------------------------------------------------------------------
 private static bool Rule13A(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule13A (name, nodeIndex.GetElementsByName ("sellerPartyReference"), errorHandler, nodeIndex));
 }
Ejemplo n.º 14
0
 //---------------------------------------------------------------------
 private static bool Rule11(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule11 (name, nodeIndex.GetElementsByName ("businessDateRange"), errorHandler));
 }
Ejemplo n.º 15
0
 //---------------------------------------------------------------------
 private static bool Rule10(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule10 (name, nodeIndex.GetElementsByName ("calculationAgent"), errorHandler));
 }
Ejemplo n.º 16
0
        // --------------------------------------------------------------------
        private static bool Rule42(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result 	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("generalTerms")) {
                XmlElement	basket			= XPath.Path (context, "basketReferenceInformation");
                XmlElement	substitution	= XPath.Path (context, "substitution");

                if ((basket == null) && (substitution != null)) {
                    errorHandler ("305", context,
                        "If basketReferenceInformation is not present then substitution must not be present.",
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 17
0
        // --------------------------------------------------------------------
        private static bool Rule43(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result 	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                if (!IsSingleName (context)) continue;

                if (!Exists (XPath.Path(context, "feeLeg", "initialPayment"))) continue;

                XmlElement	payer		= XPath.Path (context, "feeLeg", "initialPayment", "payerPartyReference");
                XmlElement	receiver 	= XPath.Path (context, "feeLeg", "initialPayment", "receiverPartyReference");
                XmlElement	seller		= XPath.Path (context, "generalTerms", "sellerPartyReference");
                XmlElement	buyer		= XPath.Path (context, "generalTerms", "buyerPartyReference");

                if ((payer != null) && (seller != null) && (receiver != null) && (buyer != null)) {
                    if (payer.GetAttribute ("href").Equals (buyer.GetAttribute ("href")) &&
                        receiver.GetAttribute ("href").Equals (seller.GetAttribute ("href")))
                        continue;
                }

                errorHandler ("305", context,
                    "The initial payment should be paid by the protection buyer to the protection seller",
                    name, null);

                result = false;
            }
            return (result);
        }
Ejemplo n.º 18
0
        // --------------------------------------------------------------------
        private static bool Rule30(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result = true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                XmlElement	paymentDate;
                XmlElement	terminationDate;

                if (And (
                    Exists (paymentDate = XPath.Path (context, "feeLeg", "periodicPayment", "lastRegularPaymentDate")),
                    Exists (terminationDate = XPath.Path (context, "generalTerms", "scheduledTerminationDate", "adjustableDate", "unadjustedDate")))) {
                    if (Less (paymentDate, terminationDate)) continue;

                    errorHandler ("305", context,
                        "Last regular periodic payment date '" + paymentDate.InnerText + "' " +
                        "must be before the termination date '" + terminationDate.InnerText + "'",
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 19
0
        // --------------------------------------------------------------------
        private static bool Rule05(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("generalTerms")) {
                if (Exists (XPath.Path (context, "scheduledTerminationDate", "adjustableDate"))) {
                    XmlNode			effectiveDate	= XPath.Path (context, "effectiveDate", "unadjustedDate");
                    XmlNode			terminationDate	= XPath.Path (context, "scheduledTerminationDate", "adjustableDate", "unadjustedDate");

                    if ((effectiveDate == null) || (terminationDate == null) || Less (effectiveDate, terminationDate ))
                        continue;

                    errorHandler ("305", context,
                        "Effective date " + effectiveDate.InnerText.Trim () + " is not " +
                        "before scheduled termination date " + terminationDate.InnerText.Trim (),
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 20
0
 // --------------------------------------------------------------------
 private static bool Rule33(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule33 (name, nodeIndex.GetElementsByName ("periodicPayment"), errorHandler));
 }
Ejemplo n.º 21
0
 // --------------------------------------------------------------------
 private static bool Rule08(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (
           Rule08 (name, nodeIndex.GetElementsByName ("trade"), errorHandler)
         & Rule08 (name, nodeIndex.GetElementsByName ("contract"), errorHandler));
 }
Ejemplo n.º 22
0
 // --------------------------------------------------------------------
 private static bool Rule34(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule34 (name, nodeIndex.GetElementsByName ("deliverableObligations"), errorHandler));
 }
Ejemplo n.º 23
0
        // --------------------------------------------------------------------
        private static bool Rule11(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement trade in nodeIndex.GetElementsByName ("trade")) {
                if (IsIsda2003 (trade) && IsLongForm (trade)) {
                    XmlElement	context = XPath.Path (trade, "creditDefaultSwap", "generalTerms", "referenceInformation") as XmlElement;

                    if (Exists (XPath.Path (context, "allGuarantees"))) continue;

                    errorHandler ("305", context,
                        "allGuarantees element missing in protection terms",
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 24
0
 // --------------------------------------------------------------------
 private static bool Rule35(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule35 (name, nodeIndex.GetElementsByName ("creditEvents"), errorHandler));
 }
Ejemplo n.º 25
0
        // --------------------------------------------------------------------
        private static bool Rule13(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                foreach (XmlElement buyer in XPath.Paths (context, "protectionTerms", "creditEvents", "creditEventNotice", "notifyingParty", "buyerPartyReference")) {
                    string		buyerName;
                    string		referenceName;

                    if (Equal (
                            buyerName = buyer.GetAttribute ("href"),
                            referenceName = XPath.Path (context, "generalTerms", "buyerPartyReference").GetAttribute ("href")))
                        continue;

                    errorHandler ("305", context,
                        "Credit event notice references buyer party reference " + buyerName +
                        " but general terms references " + referenceName,
                        name, null);

                    result = false;
                }
            }
            return (result);
        }
Ejemplo n.º 26
0
 // --------------------------------------------------------------------
 private static bool Rule36(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule36 (name, XPath.Paths (nodeIndex.GetElementsByName ("creditEvents"), "creditEventNotice", "publiclyAvailableInformation"), errorHandler));
 }
Ejemplo n.º 27
0
        // --------------------------------------------------------------------
        private static bool Rule16(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool			result = true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("creditDefaultSwap")) {
                if (Implies (
                        And (
                            Equal (
                                Count (XPath.Paths (context, "generalTerms", "referenceInformation", "referenceObligation")), 1),
                            Exists (XPath.Path (context, "cashSettlementTerms", "valuationDate", "multipleValuationDates"))),
                        Or (
                            Equal (
                                XPath.Path (context, "cashSettlementTerms", "valuationMethod"),
                                "AverageMarket"),
                            Or (
                                Equal (
                                    XPath.Path (context, "cashSettlementTerms", "valuationMethod"),
                                    "Highest"),
                                Equal (
                                    XPath.Path (context, "cashSettlementTerms", "valuationMethod"),
                                    "AverageHighest")))))
                    continue;

                errorHandler ("305", context,
                    "If there is exactly one generalTerms/referenceInformation/referenceObligation " +
                    "and cashSettlementTerms/valuationDate/multipleValuationDates occurs " +
                    "then the value of cashSettlementTerms/valuationMethod must be " +
                    "AverageMarket, Highest or AverageHighest",
                    name, XPath.Path (context, "cashSettlementTerms", "valuationMethod").InnerText);

                result = false;
            }
            return (result);
        }
Ejemplo n.º 28
0
 // --------------------------------------------------------------------
 private static bool Rule37(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
 {
     return (Rule37 (name, nodeIndex.GetElementsByName ("cashSettlementTerms"), errorHandler));
 }
        // --------------------------------------------------------------------
        private static bool Rule01(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule01 (name, nodeIndex, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "PricingDataPointCoordinate"), errorHandler));

            return (Rule01 (name, nodeIndex, nodeIndex.GetElementsByName ("coordinate"), errorHandler));
        }
Ejemplo n.º 30
0
        // --------------------------------------------------------------------
        private static bool Rule41(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            bool		result 	= true;

            foreach (XmlElement context in nodeIndex.GetElementsByName ("generalTerms")) {
                XmlElement		tranche		= XPath.Path (context, "indexReferenceInformation", "tranche");
                XmlElement		delivery	= XPath.Path (context, "modifiedEquityDelivery");

                if ((tranche == null) && (delivery != null)) {
                    errorHandler ("305", context,
                        "If indexReferenceInformation/tranche is not present then modifiedEquityDelivery must not be present.",
                        name, null);

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