Beispiel #1
0
        /// <summary>
        /// Build a tree of only one schema
        /// </summary>
        /// <param name="schemaA"></param>
        /// <returns></returns>
        public IDiffNode BuildTree(XmlSchemaObject obj)
        {
            // Setup the schema
            IDiffNode retVal = null;
            if (obj is XmlSchemaAttribute)
                retVal = new AttributeDiffNode() { Original = obj as XmlSchemaAttribute };
            else if (obj is XmlSchemaElement)
            {
                retVal = new ElementDiffNode() { Original = obj as XmlSchemaElement };
                CopyChildNodes((obj as XmlSchemaElement).SchemaType as XmlSchemaComplexType, retVal, new Stack<string>(), true);
            }
            else if (obj is XmlSchemaChoice)
            {
                retVal = new ChoiceDiffNode() { Original = obj as XmlSchemaChoice };
                CopyChildNodes(obj as XmlSchemaChoice, retVal, new Stack<string>());
                retVal = retVal.Children[0];
            }
            else if (obj is XmlSchemaSequence)
            {
                retVal = new SequenceDiffNode() { Original = obj as XmlSchemaSequence };
                CopyChildNodes(obj as XmlSchemaSequence, retVal, new Stack<string>());
                if (TreatSequenceAsNode)
                    retVal = retVal.Children[0];
            }
            else
                return null;

            return retVal;
        }
Beispiel #2
0
        private void CopyChildNodes(XmlSchemaSequence sequence, IDiffNode parent, Stack<String> typeStack)
        {
            if (sequence.Content == null || sequence.Content.Count == 0) return;

            IDiffNode seqNode = parent;

            if (TreatSequenceAsNode)
                seqNode = new SequenceDiffNode()
                {
                    Original = sequence
                };
            // Build the children of this 
            foreach (XmlSchemaObject child in sequence.Content)
                if (child is XmlSchemaChoice)
                    CopyChildNodes(child as XmlSchemaChoice, seqNode, typeStack);
                else if (child is XmlSchemaSequence)
                    CopyChildNodes(child as XmlSchemaSequence, seqNode, typeStack);
                else if (child is XmlSchemaElement)
                    CopyChildNodes(child as XmlSchemaElement, seqNode, typeStack);
                else if (child is XmlSchemaAny)
                    seqNode.AddChild(new DiffNode<XmlSchemaAny>() { Original = child as XmlSchemaAny });

            if (TreatSequenceAsNode)
                parent.AddChild(seqNode);
        }