コード例 #1
0
        private void PushReconstructedNode(ElementNode original, PrefixSpecs specs)
        {
            // For element <foo:blah> add an additional attributes like name="blah"
            var attributes = new List <AttributeNode>
            {
                new AttributeNode(specs.AttributeName, NameUtility.GetName(original.Name))
            };

            attributes.AddRange(original.Attributes);

            // Replace <foo:blah> with <foo>
            var reconstructed = new ElementNode(specs.ElementName, attributes, original.IsEmptyElement)
            {
                OriginalNode = original, Namespace = Constants.Namespace
            };

            Nodes.Add(reconstructed);

            // If it's not empty, add a frame to watch for the matching end element
            if (!original.IsEmptyElement)
            {
                PushFrame(Nodes, new Frame {
                    OriginalElementName = original.Name, Specs = specs
                });
            }
        }
コード例 #2
0
 private bool IsMatchingSpec(PrefixSpecs specs, ElementNode node)
 {
     if (base.Context.Namespaces == NamespacesType.Unqualified)
     {
         return(specs.Prefix == NameUtility.GetPrefix(node.Name));
     }
     return(specs.Namespace == node.Namespace);
 }
コード例 #3
0
        protected override void Visit(ElementNode node)
        {
            Func <PrefixSpecs, bool> predicate = null;

            if (!string.IsNullOrEmpty(NameUtility.GetPrefix(node.Name)))
            {
                if (predicate == null)
                {
                    predicate = spec => this.IsMatchingSpec(spec, node);
                }
                PrefixSpecs specs = this._prefixes.FirstOrDefault <PrefixSpecs>(predicate);
                if (specs != null)
                {
                    this.PushReconstructedNode(node, specs);
                    return;
                }
            }
            base.Visit(node);
        }
コード例 #4
0
        private void PushReconstructedNode(ElementNode original, PrefixSpecs specs)
        {
            List <AttributeNode> attributeNodes = new List <AttributeNode> {
                new AttributeNode(specs.AttributeName, NameUtility.GetName(original.Name))
            };

            attributeNodes.AddRange(original.Attributes);
            ElementNode item = new ElementNode(specs.ElementName, attributeNodes, original.IsEmptyElement)
            {
                OriginalNode = original,
                Namespace    = "http://sparkviewengine.com/"
            };

            this.Nodes.Add(item);
            if (!original.IsEmptyElement)
            {
                Frame frameData = new Frame {
                    OriginalElementName = original.Name,
                    Specs = specs
                };
                base.PushFrame(this.Nodes, frameData);
            }
        }