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

            NamespaceResolver.GetPrefixAndNs(element, _currentDocument,
                                             () => ScopeContext.Peek(),
                                             out prefix, out ns);

            if (string.IsNullOrEmpty(element.NsPrefix))
            {
                prefix = null;
            }
            //Starting Element
            if (!string.IsNullOrEmpty(element.Name))
            {
                if (element.Delimiter != DelimiterEnum.CCC)
                {
                    //not text node
                    _xmlTextWriter.WriteStartElement(prefix, element.Name, ns);
                    AddLocationMapRecord(_currentModuleMember.Module.FileName, (IMappedPair)element);

                    //Write all namespace declarations in the root element
                    if (!_rootElementAdded)
                    {
                        WritePendingNamespaceDeclarations(ns);
                        _rootElementAdded = true;
                    }
                }
            }
            else
            {
                if (element.Parent.Delimiter == DelimiterEnum.CCC && (element.Delimiter == DelimiterEnum.C || element.Delimiter == DelimiterEnum.CC))
                {
                    // This is item of explicit array (:::)
                    WriteExplicitArrayItem(element);
                }
            }

            if (!ResolveValue(element) && !EnterChoiceContainer(element, element.Entities))
            {
                base.OnElement(element);
            }

            //End Element
            if (!string.IsNullOrEmpty(element.Name))
            {
                if (element.Delimiter != DelimiterEnum.CCC) //not text node and not explicit array
                {
                    _xmlTextWriter.WriteEndElement();
                }
            }
            else
            {
                if (element.Parent.Delimiter == DelimiterEnum.CCC && (element.Delimiter == DelimiterEnum.C || element.Delimiter == DelimiterEnum.CC))
                {
                    _xmlTextWriter.WriteEndElement();
                }
            }
        }
예제 #2
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();
            }
        }
예제 #3
0
        /// <inheritdoc />
        public override void Visit(Element element)
        {
            //Getting namespace and prefix
            NamespaceResolver.GetPrefixAndNs(element, CurrentDocument, CurrentModuleMember,
                                             ScopeContext.Peek(),
                                             out var prefix, out var ns);

            if (string.IsNullOrEmpty(element.NsPrefix))
            {
                prefix = null;
            }
            //Starting Element
            if (!string.IsNullOrEmpty(element.Name))
            {
                if (element.Assignment != AssignmentEnum.CCC)
                {
                    //not text node
                    XmlTextWriter.WriteStartElement(prefix, element.Name, ns);
                    AddLocationMapRecord(CurrentModuleMember.Module.FileName, (IMappedPair)element);

                    //Write all namespace declarations in the root element
                    if (!DocumentElementAdded)
                    {
                        WritePendingNamespaceDeclarations(ns);
                        DocumentElementAdded = true;
                    }
                }
            }
            else
            {
                if (element.Parent.Assignment == AssignmentEnum.CCC && (element.Assignment == AssignmentEnum.C || element.Assignment == AssignmentEnum.CC || element.Assignment == AssignmentEnum.E || element.Assignment == AssignmentEnum.EE))
                {
                    // This is item of explicit array (:::)
                    WriteExplicitArrayItem(element, prefix, ns);
                }
            }

            if (!ResolveValue(element) && !EnterChoiceContainer(element, element.Entities))
            {
                base.Visit(element);
            }

            //End Element
            if (!string.IsNullOrEmpty(element.Name))
            {
                if (element.Assignment != AssignmentEnum.CCC) //not text node and not explicit array
                {
                    XmlTextWriter.WriteEndElement();
                }
            }
            else
            {
                if (element.Parent.Assignment == AssignmentEnum.CCC && (element.Assignment == AssignmentEnum.C || element.Assignment == AssignmentEnum.CC || element.Assignment == AssignmentEnum.E || element.Assignment == AssignmentEnum.EE))
                {
                    XmlTextWriter.WriteEndElement();
                }
            }
        }
예제 #4
0
        public override void OnAttribute(DOM.Attribute node)
        {
            string prefix, ns;

            _context.NamespaceResolver.GetPrefixAndNs(node, _currentDocument,
                                                      () => 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));
        }
예제 #5
0
        private void WriteExplicitArrayItem(Element element)
        {
            string prefix;
            string ns;

            NamespaceResolver.GetPrefixAndNs((INsNode)element.Parent, _currentDocument,
                                             () => ScopeContext.Peek(),
                                             out prefix, out ns);
            if (string.IsNullOrEmpty(element.NsPrefix))
            {
                prefix = null;
            }
            _xmlTextWriter.WriteStartElement(prefix, element.Parent.Name, ns);
            AddLocationMapRecord(_currentModuleMember.Module.FileName, (IMappedPair)element);
        }
예제 #6
0
        public override void OnAttribute(DOM.Attribute attribute)
        {
            string prefix = string.Empty, ns = string.Empty;

            if (!string.IsNullOrEmpty(attribute.NsPrefix))
            {
                NamespaceResolver.GetPrefixAndNs(attribute, _currentDocument,
                                                 () => ScopeContext.Peek(),
                                                 out prefix, out ns);
            }
            _xmlTextWriter.WriteStartAttribute(prefix, attribute.Name, ns);
            if (!ResolveValue(attribute))
            {
                EnterChoiceContainer(attribute, new PairCollection <Entity>().AddRange(((DOM.Mapped.Attribute)attribute).InterpolationItems?.OfType <Entity>()));
            }
            _xmlTextWriter.WriteEndAttribute();

            AddLocationMapRecord(_currentModuleMember.Module.FileName, (IMappedPair)attribute);
        }