lib/xml-reader.js
function getDataSource(node) {
    const config = Object.assign({}, copyXmlAttributes(node));

    if (node.childNodes.length) {
        // parse datasource options
        for (let i = 0; i < node.childNodes.length; ++i) {
            const childNode = node.childNodes.item(i);

            if (childNode.nodeType === TEXT_NODE && childNode.textContent.trim().length > 0) {
                throw new ImplementationError(`dataSource contains useless text: "${childNode.textContent.trim()}"`);
            }

            if (
                childNode.nodeType === ELEMENT_NODE &&
                childNode.namespaceURI === 'urn:flora:options' &&
                childNode.localName === 'option'
            ) {
                if (childNode.attributes.length !== 1)
                    throw new Error('flora:option element requires a name attribute');

                const attr = childNode.attributes.item(0);
                if (attr.localName !== 'name') throw new Error('flora:option element requires a name attribute');
                if (config[attr.value]) throw new Error(`Data source option "${attr.value}" already defined`);

                config[attr.value] = childNode.textContent.trim();
            }
        }
    }

    const name = config.name ? config.name : 'primary';
    if (config.name) delete config.name;

    return { name, config };
}
function getDataSource(node) {
    const config = Object.assign({}, copyXmlAttributes(node));

    if (node.childNodes.length) {
        // parse datasource options
        for (let i = 0; i < node.childNodes.length; ++i) {
            const childNode = node.childNodes.item(i);

            if (childNode.nodeType === TEXT_NODE && childNode.textContent.trim().length > 0) {
                throw new ImplementationError(`dataSource contains useless text: "${childNode.textContent.trim()}"`);
            }

            if (
                childNode.nodeType === ELEMENT_NODE &&
                childNode.namespaceURI === 'urn:flora:options' &&
                childNode.localName === 'option'
            ) {
                if (childNode.attributes.length !== 1)
                    throw new Error('flora:option element requires a name attribute');

                const attr = childNode.attributes.item(0);
                if (attr.localName !== 'name') throw new Error('flora:option element requires a name attribute');
                if (config[attr.value]) throw new Error(`Data source option "${attr.value}" already defined`);

                config[attr.value] = childNode.textContent.trim();
            }
        }
    }

    const name = config.name ? config.name : 'primary';
    if (config.name) delete config.name;

    return { name, config };
}
function getDataSource ( node ) { const config = Object . assign ( { } , copyXmlAttributes ( node ) ) ; if ( node . childNodes . length ) { // parse datasource options for ( let i = 0 ; i < node . childNodes . length ; ++ i ) { const childNode = node . childNodes . item ( i ) ; if ( childNode . nodeType === TEXT_NODE && childNode . textContent . trim ( ) . length > 0 ) { throw new ImplementationError ( ` ${ childNode . textContent . trim ( ) } ` ) ; } if ( childNode . nodeType === ELEMENT_NODE && childNode . namespaceURI === 'urn:flora:options' && childNode . localName === 'option' ) { if ( childNode . attributes . length !== 1 ) throw new Error ( 'flora:option element requires a name attribute' ) ; const attr = childNode . attributes . item ( 0 ) ; if ( attr . localName !== 'name' ) throw new Error ( 'flora:option element requires a name attribute' ) ; if ( config [ attr . value ] ) throw new Error ( ` ${ attr . value } ` ) ; config [ attr . value ] = childNode . textContent . trim ( ) ; } } } const name = config . name ? config . name : 'primary' ; if ( config . name ) delete config . name ; return { name , config } ; }
Extract config from dataSource nodes.

@param {Node} node
@return {Object}
@private
Extract config from dataSource nodes .