function appendElement(el, domBuilder, currentNSMap) {
    const tagName = el.tagName;
    let prefix;
    let localName;
    let localNSMap = null;
    let nsp;
    // const currentNSMap = parseStack[parseStack.length-1].currentNSMap;
    let i = el.length;
    while (i--) {
        const a = el[i];
        const qName = a.qName;
        const value = a.value;
        nsp = qName.indexOf(':');
        let nsPrefix;
        if (nsp > 0) {
            prefix = a.prefix = qName.slice(0, nsp);
            localName = qName.slice(nsp + 1);
            nsPrefix = prefix === 'xmlns' && localName;
        }
        else {
            localName = qName;
            prefix = null;
            nsPrefix = qName === 'xmlns' && '';
        }
        // can not set prefix,because prefix !== ''
        a.localName = localName;
        // prefix == null for no ns prefix attribute
        if (nsPrefix !== false) {
            // hack!!
            if (localNSMap == null) {
                localNSMap = {};
                // console.log(currentNSMap,0)
                _copy(currentNSMap, (currentNSMap = {}));
                // console.log(currentNSMap,1)
            }
            currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
            a.uri = 'http://www.w3.org/2000/xmlns/';
            domBuilder.startPrefixMapping(nsPrefix, value);
        }
    }
    i = el.length;
    while (i--) {
        const a = el[i];
        prefix = a.prefix;
        if (prefix) {
            // no prefix attribute has no namespace
            if (prefix === 'xml') {
                a.uri = 'http://www.w3.org/XML/1998/namespace';
            }
            if (prefix !== 'xmlns') {
                a.uri = currentNSMap[prefix || ''];
                // {console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)}
            }
        }
    }
    nsp = tagName.indexOf(':');
    if (nsp > 0) {
        prefix = el.prefix = tagName.slice(0, nsp);
        localName = el.localName = tagName.slice(nsp + 1);
    }
    else {
        prefix = null; // important!!
        localName = el.localName = tagName;
    }
    // no prefix element has default namespace
    const ns = (el.uri = currentNSMap[prefix || '']);
    domBuilder.startElement(ns, localName, tagName, el);
    // endPrefixMapping and startPrefixMapping have not any help for dom builder
    // localNSMap = null
    if (el.closed) {
        domBuilder.endElement(ns, localName, tagName);
        if (localNSMap) {
            for (const p of Object.keys(localNSMap)) {
                domBuilder.endPrefixMapping(p);
            }
        }
    }
    else {
        el.currentNSMap = currentNSMap;
        el.localNSMap = localNSMap;
        // parseStack.push(el);
        return true;
    }
}
/**
 * @return true if has new namespace define
 */
@return true if has new namespace define
@return true if has new namespace define
function appendElement(el, domBuilder, currentNSMap) {
    const tagName = el.tagName;
    let prefix;
    let localName;
    let localNSMap = null;
    let nsp;
    let i = el.length;
    while (i--) {
        const a = el[i];
        const qName = a.qName;
        const value = a.value;
        nsp = qName.indexOf(':');
        let nsPrefix;
        if (nsp > 0) {
            prefix = a.prefix = qName.slice(0, nsp);
            localName = qName.slice(nsp + 1);
            nsPrefix = prefix === 'xmlns' && localName;
        }
        else {
            localName = qName;
            prefix = null;
            nsPrefix = qName === 'xmlns' && '';
        }
        a.localName = localName;
        if (nsPrefix !== false) {
            if (localNSMap == null) {
                localNSMap = {};
                _copy(currentNSMap, (currentNSMap = {}));
            }
            currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
            a.uri = 'http://www.w3.org/2000/xmlns/';
            domBuilder.startPrefixMapping(nsPrefix, value);
        }
    }
    i = el.length;
    while (i--) {
        const a = el[i];
        prefix = a.prefix;
        if (prefix) {
            if (prefix === 'xml') {
                a.uri = 'http://www.w3.org/XML/1998/namespace';
            }
            if (prefix !== 'xmlns') {
                a.uri = currentNSMap[prefix || ''];
            }
        }
    }
    nsp = tagName.indexOf(':');
    if (nsp > 0) {
        prefix = el.prefix = tagName.slice(0, nsp);
        localName = el.localName = tagName.slice(nsp + 1);
    }
    else {
        prefix = null; 
        localName = el.localName = tagName;
    }
    const ns = (el.uri = currentNSMap[prefix || '']);
    domBuilder.startElement(ns, localName, tagName, el);
    if (el.closed) {
        domBuilder.endElement(ns, localName, tagName);
        if (localNSMap) {
            for (const p of Object.keys(localNSMap)) {
                domBuilder.endPrefixMapping(p);
            }
        }
    }
    else {
        el.currentNSMap = currentNSMap;
        el.localNSMap = localNSMap;
        return true;
    }
}
function appendElement ( el , domBuilder , currentNSMap ) { const tagName = el . tagName ; let prefix ; let localName ; let localNSMap = null ; let nsp ; let i = el . length ; while ( i -- ) { const a = el [ i ] ; const qName = a . qName ; const value = a . value ; nsp = qName . indexOf ( ':' ) ; let nsPrefix ; if ( nsp > 0 ) { prefix = a . prefix = qName . slice ( 0 , nsp ) ; localName = qName . slice ( nsp + 1 ) ; nsPrefix = prefix === 'xmlns' && localName ; } else { localName = qName ; prefix = null ; nsPrefix = qName === 'xmlns' && '' ; } a . localName = localName ; if ( nsPrefix !== false ) { if ( localNSMap == null ) { localNSMap = { } ; _copy ( currentNSMap , ( currentNSMap = { } ) ) ; } currentNSMap [ nsPrefix ] = localNSMap [ nsPrefix ] = value ; a . uri = 'http://www.w3.org/2000/xmlns/' ; domBuilder . startPrefixMapping ( nsPrefix , value ) ; } } i = el . length ; while ( i -- ) { const a = el [ i ] ; prefix = a . prefix ; if ( prefix ) { if ( prefix === 'xml' ) { a . uri = 'http://www.w3.org/XML/1998/namespace' ; } if ( prefix !== 'xmlns' ) { a . uri = currentNSMap [ prefix || '' ] ; } } } nsp = tagName . indexOf ( ':' ) ; if ( nsp > 0 ) { prefix = el . prefix = tagName . slice ( 0 , nsp ) ; localName = el . localName = tagName . slice ( nsp + 1 ) ; } else { prefix = null ; localName = el . localName = tagName ; } const ns = ( el . uri = currentNSMap [ prefix || '' ] ) ; domBuilder . startElement ( ns , localName , tagName , el ) ; if ( el . closed ) { domBuilder . endElement ( ns , localName , tagName ) ; if ( localNSMap ) { for ( const p of Object . keys ( localNSMap ) ) { domBuilder . endPrefixMapping ( p ) ; } } } else { el . currentNSMap = currentNSMap ; el . localNSMap = localNSMap ; return true ; } }
@return true if has new namespace define
@return true if has new namespace define
// const currentNSMap = parseStack[parseStack.length-1].currentNSMap; // can not set prefix,because prefix !== '' // prefix == null for no ns prefix attribute // hack!! // console.log(currentNSMap,0) // console.log(currentNSMap,1) // no prefix attribute has no namespace // {console.log('###'+a.qName,domBuilder.locator.systemId+'',currentNSMap,a.uri)} // important!! // no prefix element has default namespace // endPrefixMapping and startPrefixMapping have not any help for dom builder // localNSMap = null // parseStack.push(el);