GetElementsByType() public method

Creates a (possibly empty) XmlNodeList containing all the element nodes of a given type (or a derived subtype).
public GetElementsByType ( string ns, string type ) : XmlNodeList
ns string The required namespace URI.
type string The required type.
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)
        {
            if (nodeIndex.HasTypeInformation) {
                string ns = FpMLRuleSet.DetermineNamespace (nodeIndex);

                foreach (string type in types) {
                    XmlNodeList list = nodeIndex.GetElementsByType (ns, type);

                    if ((list != null) && (list.Count > 0)) return (true);
                }
            }
            else {
                foreach (String element in elements) {
                    XmlNodeList list = nodeIndex.GetElementsByName (element);

                    if ((list != null) && (list.Count > 0)) return (true);
                }
            }
            return (false);
        }
Exemplo n.º 2
0
        // --------------------------------------------------------------------
        private static bool Rule51(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule51 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxSwapLeg"), errorHandler));

            return (
                      Rule51 (name, nodeIndex.GetElementsByName ("nearLeg"), errorHandler)
                    & Rule51 (name, nodeIndex.GetElementsByName ("farLeg"), errorHandler));
        }
Exemplo n.º 3
0
        // --------------------------------------------------------------------
        private static bool Rule48(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule48 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxAsianFeature"), errorHandler));

            return (
                      Rule48 (name, nodeIndex.GetElementsByName ("asian"), errorHandler));
        }
Exemplo n.º 4
0
        // --------------------------------------------------------------------
        private static bool Rule25_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule25_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "Schedule"), errorHandler));

            return (
                  Rule25_OLD (name, nodeIndex.GetElementsByName ("feeRateSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("floatingRateMultiplierSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("spreadSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("fixedRateSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("capRateSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("floorRateSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("feeAmountSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("knownAmountSchedule"), errorHandler)
                & Rule25_OLD (name, nodeIndex.GetElementsByName ("notionalStepSchedule"), errorHandler));
        }
        // --------------------------------------------------------------------
        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));
        }
Exemplo n.º 6
0
        // --------------------------------------------------------------------
        private static bool Rule10(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule10 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FacilityNotice"), errorHandler));

            return (
                      Rule10 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FacilityNotice"), errorHandler));
        }
Exemplo n.º 7
0
        // --------------------------------------------------------------------
        private static bool Rule01(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule01 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "LoanContract"), errorHandler));

            return (
                  Rule01 (name, nodeIndex.GetElementsByName ("loanContract"), errorHandler));
        }
Exemplo n.º 8
0
        // --------------------------------------------------------------------
        private static bool Rule09_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule09_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FXAverageRateObservationSchedule"), errorHandler)
                    & Rule09_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxAverageRateObservationSchedule"), errorHandler));

            return (
                  Rule09_OLD (name, nodeIndex.GetElementsByName ("averageRateObservationSchedule"), errorHandler));
        }
Exemplo n.º 9
0
        // --------------------------------------------------------------------
        private static bool Rule09(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule01(name, nodeIndex.GetElementsByType(DetermineNamespace(nodeIndex), "InterestRateStream"), errorHandler));

            return (
                  Rule09 (name, nodeIndex.GetElementsByName ("swapStream"), errorHandler)
                & Rule09 (name, nodeIndex.GetElementsByName ("capFloorStream"), errorHandler));
        }
Exemplo n.º 10
0
        // --------------------------------------------------------------------
        private static bool Rule61(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule61 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "NonNegativeSchedule"), errorHandler));

            return (
                  Rule61 (name, nodeIndex.GetElementsByName ("notionalStepSchedule"), errorHandler));
        }
Exemplo n.º 11
0
        // --------------------------------------------------------------------
        private static bool Rule49(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule47 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "ResetFrequency"), errorHandler));

            return (Rule49 (name, nodeIndex.GetElementsByName ("resetFrequency"), errorHandler));
        }
Exemplo n.º 12
0
        // --------------------------------------------------------------------
        private static bool Rule47(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule47 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "OptionalEarlyTermination"), errorHandler));

            return (Rule47 (name, nodeIndex.GetElementsByName ("optionalEarlyTermination"), errorHandler));
        }
Exemplo n.º 13
0
        // --------------------------------------------------------------------
        private static bool Rule44(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule44 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "MandatoryEarlyTerminationAdjustedDates"), errorHandler));

            return (Rule44 (name, nodeIndex.GetElementsByName ("mandatoryEarlyTerminationAdjustedDates"), errorHandler));
        }
Exemplo n.º 14
0
        // --------------------------------------------------------------------
        private static bool Rule43(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule43 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxLinkedNotionalAmount"), errorHandler));

            return (Rule43 (name, nodeIndex.GetElementsByName ("fxLinkedNotionalAmount"), errorHandler));
        }
Exemplo n.º 15
0
        // --------------------------------------------------------------------
        private static bool Rule26(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule26 (name, nodeIndex, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "BusinessCentersReference"), errorHandler));

            return (
                  Rule26 (name, nodeIndex, nodeIndex.GetElementsByName ("businessCentersReference"), errorHandler));
        }
Exemplo n.º 16
0
        // --------------------------------------------------------------------
        private static bool Rule06_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule06_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "ExchangeRate"), errorHandler));

            return (
                  Rule06_OLD (name, nodeIndex.GetElementsByName ("exchangeRate"), errorHandler));
        }
Exemplo n.º 17
0
        // --------------------------------------------------------------------
        private static bool Rule08_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule08_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FXAmericanTrigger"), errorHandler)
                    & Rule08_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxAmericanTrigger"), errorHandler));

            return (
                  Rule08_OLD (name, nodeIndex.GetElementsByName ("fxAmericanTrigger"), errorHandler));
        }
Exemplo n.º 18
0
        // --------------------------------------------------------------------
        private static bool Rule23_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule23_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FXOptionLeg"), errorHandler)
                    & Rule23_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxOptionLeg"), errorHandler));

            return (
                  Rule23_OLD (name, nodeIndex.GetElementsByName ("fxSimpleOption"), errorHandler)
                & Rule23_OLD (name, nodeIndex.GetElementsByName ("fxBarrierOption"), errorHandler));
        }
Exemplo n.º 19
0
        /// <summary>
        /// Validates all the elements registered at construction using the
        /// <see cref="NodeIndex"/> to locate them as quickly as possible.
        /// </summary>
        /// <param name="nodeIndex">The <see cref="NodeIndex"/> of the test document.</param>
        /// <param name="errorHandler">The <see cref="ValidationErrorHandler"/> used to report issues.</param>
        /// <returns><c>true</c> if the code values pass the checks, <c>false</c>
        /// otherwise.</returns>
        protected override bool Validate(NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation) {
                string ns = FpMLRuleSet.DetermineNamespace (nodeIndex);

                return (Validate (
                            nodeIndex.GetElementsByType (ns, contextType),
                            nodeIndex.GetElementsByType (ns, targetType), errorHandler));
            }

            return (Validate (
                        nodeIndex.GetElementsByName (contextElements),
                        nodeIndex.GetElementsByName (targetElements), errorHandler));
        }
Exemplo n.º 20
0
        // --------------------------------------------------------------------
        private static bool Rule27(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule27 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "QuotedCurrencyPair"), errorHandler));

            return (
                  Rule27 (name, nodeIndex.GetElementsByName ("quotedCurrencyPair"), errorHandler));
        }
Exemplo n.º 21
0
        // --------------------------------------------------------------------
        private static bool Rule05(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule05 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "InterestRatePeriod"), errorHandler));

            return (
                  Rule05 (name, nodeIndex.GetElementsByName ("currentInterestRatePeriod"), errorHandler));
        }
Exemplo n.º 22
0
        // --------------------------------------------------------------------
        private static bool Rule30_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule30_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "SideRate"), errorHandler));

            return (
                      Rule30_OLD (name, nodeIndex.GetElementsByName ("currency1SideRate"), errorHandler)
                    & Rule30_OLD (name, nodeIndex.GetElementsByName ("currency2SideRate"), errorHandler));
        }
Exemplo n.º 23
0
        //---------------------------------------------------------------------
        private static bool Rule01(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation) {
                String ns = nodeIndex.Document.DocumentElement.NamespaceURI;
                return (Rule01 (name, nodeIndex.GetElementsByType (ns, "BusinessDayAdjustments"), errorHandler));
            }

            return (
                Rule01 (name, nodeIndex.GetElementsByName ("dateAdjustments"), errorHandler)
              & Rule01 (name, nodeIndex.GetElementsByName ("calculationPeriodDatesAdjustments"), errorHandler)
              & Rule01 (name, nodeIndex.GetElementsByName ("paymentDatesAdjustments"), errorHandler)
              & Rule01 (name, nodeIndex.GetElementsByName ("resetDatesAdjustments"), errorHandler));
        }
Exemplo n.º 24
0
        // --------------------------------------------------------------------
        private static bool Rule33(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (Rule33 (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "TermDeposit"), errorHandler));

            return (
                      Rule33 (name, nodeIndex.GetElementsByName ("termDeposit"), 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));
        }
Exemplo n.º 26
0
        // --------------------------------------------------------------------
        private static bool Rule45_OLD(string name, NodeIndex nodeIndex, ValidationErrorHandler errorHandler)
        {
            if (nodeIndex.HasTypeInformation)
                return (
                      Rule45_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FXDigitalOption"), errorHandler)
                    & Rule45_OLD (name, nodeIndex.GetElementsByType (DetermineNamespace (nodeIndex), "FxDigitalOption"), errorHandler));

            return (
                  Rule45_OLD (name, nodeIndex.GetElementsByName ("fxDigitalOption"), errorHandler));
        }