Esempio n. 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();
            }
        }
Esempio n. 2
0
        protected NsInfo GetContextNsInfo()
        {
            if (AliasContext.Peek() == null)
            {
                return(_context.NamespaceResolver.GetNsInfo(_currentDocument));
            }

            return(_context.NamespaceResolver.GetNsInfo(AliasContext.Peek().AliasDefinition));
        }
Esempio n. 3
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));
        }