예제 #1
0
        private void _enterElement(ASXML elem)
        {
            _writeIndent();

            ASQName elemName  = elem.internalGetName() !;
            var     stackItem = new TagStackItem {
                tempPrefixIdStart = m_nextTempPrefixId,
                nsDeclBeginIndex  = m_nsInScope.length,
                localName         = elemName.localName,
                prefix            = _getPrefix(elemName, isAttr: false)
            };

            elem.internalGetNamespaceDecls(ref m_nsInScope);

            m_parts.add("<");
            _writeName(stackItem.prefix, stackItem.localName);

            foreach (ASXML attr in elem.getAttributeEnumerator())
            {
                ASQName attrName  = attr.internalGetName() !;
                string  attrValue = attr.nodeText !;

                m_parts.add(" ");
                _writeName(_getPrefix(attrName, isAttr: true), attrName.localName);
                m_parts.add("=\"");
                m_parts.add(XMLHelper.escape(attrValue, 0, attrValue.Length, ref m_escBuffer, isAttr: true));
                m_parts.add("\"");
            }

            // If this is the root we must include the ancestor namespaces as well.
            int nsDeclStart = (m_tagStack.length == 0) ? 0 : stackItem.nsDeclBeginIndex;

            for (int i = nsDeclStart, n = m_nsInScope.length; i < n; i++)
            {
                ASNamespace nsDecl = m_nsInScope[i];

                if (nsDecl.prefix !.Length != 0)
                {
                    m_parts.add(" xmlns:");
                    m_parts.add(nsDecl.prefix);
                    m_parts.add("=\"");
                }
예제 #2
0
        TagStackItem AddTagToStack(Tag tag, List<TagAttribute> cleanAttributes)
        {
            // Set tag attributes to contain only normal HTML/XML attributes (TAL/METAL attributes are removed)
            tag.Attributes = cleanAttributes;

            // Add tag to tag stack
            var tagStackItem = new TagStackItem(tag);
            _tagStack.Add(tagStackItem);
            return tagStackItem;
        }