const utils = require('./utils.js'); /** * Sets the namespace to use for the specified `Document`. * @param {Document} xmlDoc The `Document` instance to set the namespace of. * @param {string} alias The namespace alias. * @param {string} url The namespace URL. */ function setNamespace(xmlDoc, alias, url) { if (!xmlDoc) throw new Error('A Document must be provided.'); if (typeof alias !== 'string') throw new Error('alias must be a string.'); if (typeof url !== 'string') throw new Error('url must be a string.'); if (!utils.isValidURL(url)) throw new Error('url is not a valid URL.'); xmlDoc.namespace = { alias, url, }; } module.exports = setNamespace;