Exemple #1
0
        public override void OnElement(Element node)
        {
            //Getting namespace and prefix
            string prefix, ns;

            _context.NamespaceResolver.GetPrefixAndNs(node, _currentDocument,
                                                      () => { var aliasContext = AliasContext.Peek(); return(aliasContext?.AliasDefinition); },
                                                      () => ScopeContext.Peek(),
                                                      out prefix, out ns);

            //Starting Element
            if (!string.IsNullOrEmpty(node.Name)) //not text node
            {
                _xmlTextWriter.WriteStartElement(prefix, node.Name, ns);
            }
            LocationMap.Add(new LexicalInfo(_currentDocument.Module.FileName, node.start.Line, node.start.Column, node.start.Index));

            //Write all namespace declarations in the root element
            if (!_rootElementAdded)
            {
                WritePendingNamespaceDeclarations(ns);
                _rootElementAdded = true;
            }

            if (!ResolveValue(node))
            {
                base.OnElement(node);
            }

            //End Element
            if (!string.IsNullOrEmpty(node.Name)) //not text node
            {
                _xmlTextWriter.WriteEndElement();
            }
        }
Exemple #2
0
        protected NsInfo GetContextNsInfo()
        {
            if (AliasContext.Peek() == null)
            {
                return(_context.NamespaceResolver.GetNsInfo(_currentDocument));
            }

            return(_context.NamespaceResolver.GetNsInfo(AliasContext.Peek().AliasDefinition));
        }
Exemple #3
0
        protected string ResolveValueAlias(Alias alias, out ValueType valueType)
        {
            var aliasDef = _context.NamespaceResolver.GetAliasDefinition(alias.Name);

            AliasContext.Push(new AliasContext {
                AliasDefinition = aliasDef, Alias = alias, AliasNsInfo = GetContextNsInfo()
            });

            var result = aliasDef.ObjectValue == null?ResolveNodeValue(aliasDef, out valueType) : ResolveObjectValue(aliasDef.ObjectValue, out valueType);

            AliasContext.Pop();

            return(result);
        }
Exemple #4
0
        public override void OnAttribute(DOM.Attribute node)
        {
            string prefix, ns;

            _context.NamespaceResolver.GetPrefixAndNs(node, _currentDocument,
                                                      () => { var aliasContext = AliasContext.Peek(); return(aliasContext?.AliasDefinition); },
                                                      () => ScopeContext.Peek(),
                                                      out prefix, out ns);

            _xmlTextWriter.WriteStartAttribute(prefix, node.Name, ns);
            ResolveValue(node);
            _xmlTextWriter.WriteEndAttribute();

            LocationMap.Add(new LexicalInfo(_currentDocument.Module.FileName, node.start.Line, node.start.Column, node.start.Index));
        }
Exemple #5
0
        public override void OnAlias(Alias alias)
        {
            var aliasDef = ((DOM.Antlr.Alias)alias).AliasDefinition;

            //Do not resolve alias without AliasDef or having circular reference
            if (aliasDef == DOM.Antlr.AliasDefinition.Undefined || aliasDef.HasCircularReference)
            {
                return;
            }

            AliasContext.Push(new AliasContext()
            {
                AliasDefinition = aliasDef, Alias = alias, AliasNsInfo = GetContextNsInfo()
            });
            Visit(aliasDef.Entities.Where(e => !(e is Attribute)));
            AliasContext.Pop();
        }
Exemple #6
0
        private void ResolveAttributesInAlias(Alias alias)
        {
            var aliasDef = ((DOM.Antlr.Alias)alias).AliasDefinition;

            //Do not resolve alias without AliasDef or having circular reference
            if (aliasDef == DOM.Antlr.AliasDefinition.Undefined || aliasDef.HasCircularReference)
            {
                return;
            }

            AliasContext.Push(new AliasContext()
            {
                AliasDefinition = aliasDef, Alias = alias, AliasNsInfo = GetContextNsInfo()
            });
            ResolveAttributes(aliasDef.Entities);
            AliasContext.Pop();
        }