示例#1
0
        /// <summary>The outermost call is special.</summary>
        /// <remarks>
        /// The outermost call is special. The names almost certainly differ. The
        /// qualifiers (and hence options) will differ for an alias to the x-default
        /// item of a langAlt array.
        /// </remarks>
        /// <param name="aliasNode">the alias node</param>
        /// <param name="baseNode">the base node of the alias</param>
        /// <param name="outerCall">marks the outer call of the recursion</param>
        /// <exception cref="iText.Kernel.XMP.XMPException">Forwards XMP errors</exception>
        private static void CompareAliasedSubtrees(XMPNode aliasNode, XMPNode baseNode, bool
                                                   outerCall)
        {
            if (!aliasNode.GetValue().Equals(baseNode.GetValue()) ||
                aliasNode.GetChildrenLength() != baseNode.GetChildrenLength())
            {
                throw new XMPException("Mismatch between alias and base nodes", XMPError.BADXMP);
            }

            if (!outerCall &&
                (!aliasNode.GetName().Equals(baseNode.GetName()) || !aliasNode.GetOptions().Equals(baseNode.GetOptions()) ||
                 aliasNode.GetQualifierLength() != baseNode.GetQualifierLength()))
            {
                throw new XMPException("Mismatch between alias and base nodes", XMPError.BADXMP);
            }

            for (IEnumerator an = aliasNode.IterateChildren(), bn = baseNode.IterateChildren();
                 an.MoveNext() && bn.MoveNext();)
            {
                XMPNode aliasChild = (XMPNode)an.Current;
                XMPNode baseChild  = (XMPNode)bn.Current;
                CompareAliasedSubtrees(aliasChild, baseChild, false);
            }


            for (IEnumerator an = aliasNode.IterateQualifier(), bn = baseNode.IterateQualifier();
                 an.MoveNext() && bn.MoveNext();)
            {
                XMPNode aliasQual = (XMPNode)an.Current;
                XMPNode baseQual  = (XMPNode)bn.Current;
                CompareAliasedSubtrees(aliasQual, baseQual, false);
            }
        }