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AAgB,GAAQ,KAAO,EAAO,IAAM,EAGrF,OAAO,CACR,EAEI,aAAe,QAAQ,YAAc,SAAsB,EAAK,GAGnE,GAAI,EAAK,CACR,GAAyB,iBAAb,EAAI,SAAkD,IAApB,EAAI,GAAW,OAAmB,CAC/E,IAAI,EAAO,EAAI,UACR,EAAI,GACX,EAAI,GAAO,IAAI,MACf,EAAI,GAAK,GAAK,CACf,CACA,OAAO,IACR,CAEC,MAAoB,iBAAT,QAA6C,IAAf,EAAU,OAA4B,CAAE,GACrE,CAEd,EAEI,mBAAqB,QAAQ,gBAAkB,SAA4B,GAE9E,IAAI,EAAQ,GACZ,IAAK,IAAI,KAAO,EAAM,EAAM,KAAK,GACjC,OAAO,CACR,EAEI,UAAY,QAAQ,SAAW,SAAmB,GAErD,OAAO,QAAQ,EAChB,EAEI,SAAW,QAAQ,QAAU,SAAkB,GAElD,QAAU,GAAuB,iBAAT,IAAuB,UAAU,EAC1D,EAEI,UAAY,QAAQ,SAAW,SAAmB,GAErD,IAAK,IAAI,KAAO,EAAM,OAAO,EAC7B,OAAO,IACR,EAEI,SAAW,QAAQ,QAAU,SAAkB,GAElD,IAAI,EAAQ,EACZ,IAAK,IAAI,KAAK,EAAM,IACpB,OAAO,CACR","file":"/npm/pixl-xml@1.0.13/xml.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.37.0.\n * Original file: /npm/pixl-xml@1.0.13/xml.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/*\n\tJavaScript XML Library\n\tPlus a bunch of object utility functions\n\t\n\tUsage:\n\t\tvar XML = require('pixl-xml');\n\t\tvar myxmlstring = '<?xml version=\"1.0\"?><Document>' + \n\t\t\t'<Simple>Hello</Simple>' + \n\t\t\t'<Node Key=\"Value\">Content</Node>' + \n\t\t\t'</Document>';\n\t\t\n\t\tvar tree = XML.parse( myxmlstring, { preserveAttributes: true });\n\t\tconsole.log( tree );\n\t\t\n\t\ttree.Simple = \"Hello2\";\n\t\ttree.Node._Attribs.Key = \"Value2\";\n\t\ttree.Node._Data = \"Content2\";\n\t\ttree.New = \"I added this\";\n\t\t\n\t\tconsole.log( XML.stringify( tree, 'Document' ) );\n\t\n\tCopyright (c) 2004 - 2015 Joseph Huckaby\n\tReleased under the MIT License\n\tThis version is for Node.JS, converted in 2012.\n*/\n\nvar fs = require('fs');\nvar util = require('util');\n\nvar isArray = Array.isArray || util.isArray; // support for older Node.js\n\nvar xml_header = '<?xml version=\"1.0\"?>';\nvar sort_args = null;\nvar re_valid_tag_name  = /^\\w[\\w\\-\\:\\.]*$/;\n\nvar XML = exports.XML = exports.Parser = function XML(args, opts) {\n\t// class constructor for XML parser class\n\t// pass in args hash or text to parse\n\tif (!args) args = '';\n\tif (isa_hash(args)) {\n\t\tfor (var key in args) this[key] = args[key];\n\t}\n\telse this.text = args || '';\n\t\n\t// options may be 2nd argument as well\n\tif (opts) {\n\t\tfor (var key in opts) this[key] = opts[key];\n\t}\n\t\n\t// stringify buffers\n\tif (this.text instanceof Buffer) {\n\t\tthis.text = this.text.toString();\n\t}\n\t\n\tif (!this.text.match(/^\\s*</)) {\n\t\t// try as file path\n\t\tvar file = this.text;\n\t\tthis.text = fs.readFileSync(file, { encoding: 'utf8' });\n\t\tif (!this.text) throw new Error(\"File not found: \" + file);\n\t}\n\t\n\tthis.tree = {};\n\tthis.errors = [];\n\tthis.piNodeList = [];\n\tthis.dtdNodeList = [];\n\tthis.documentNodeName = '';\n\t\n\tif (this.lowerCase) {\n\t\tthis.attribsKey = this.attribsKey.toLowerCase();\n\t\tthis.dataKey = this.dataKey.toLowerCase();\n\t}\n\t\n\tthis.patTag.lastIndex = 0;\n\tif (this.text) this.parse();\n}\n\nXML.prototype.preserveDocumentNode = false;\nXML.prototype.preserveAttributes = false;\nXML.prototype.preserveWhitespace = false;\nXML.prototype.lowerCase = false;\nXML.prototype.forceArrays = false;\n\nXML.prototype.patTag = /([^<]*?)<([^>]+)>/g;\nXML.prototype.patSpecialTag = /^\\s*([\\!\\?])/;\nXML.prototype.patPITag = /^\\s*\\?/;\nXML.prototype.patCommentTag = /^\\s*\\!--/;\nXML.prototype.patDTDTag = /^\\s*\\!DOCTYPE/;\nXML.prototype.patCDATATag = /^\\s*\\!\\s*\\[\\s*CDATA/;\nXML.prototype.patStandardTag = /^\\s*(\\/?)([\\w\\-\\:\\.]+)\\s*([\\s\\S]*)$/;\nXML.prototype.patSelfClosing = /\\/\\s*$/;\nXML.prototype.patAttrib = new RegExp(\"([\\\\w\\\\-\\\\:\\\\.]+)\\\\s*=\\\\s*([\\\\\\\"\\\\'])([^\\\\2]*?)\\\\2\", \"g\");\nXML.prototype.patPINode = /^\\s*\\?\\s*([\\w\\-\\:]+)\\s*(.*)$/;\nXML.prototype.patEndComment = /--$/;\nXML.prototype.patNextClose = /([^>]*?)>/g;\nXML.prototype.patExternalDTDNode = new RegExp(\"^\\\\s*\\\\!DOCTYPE\\\\s+([\\\\w\\\\-\\\\:]+)\\\\s+(SYSTEM|PUBLIC)\\\\s+\\\\\\\"([^\\\\\\\"]+)\\\\\\\"\");\nXML.prototype.patInlineDTDNode = /^\\s*\\!DOCTYPE\\s+([\\w\\-\\:]+)\\s+\\[/;\nXML.prototype.patEndDTD = /\\]$/;\nXML.prototype.patDTDNode = /^\\s*\\!DOCTYPE\\s+([\\w\\-\\:]+)\\s+\\[(.*)\\]/;\nXML.prototype.patEndCDATA = /\\]\\]$/;\nXML.prototype.patCDATANode = /^\\s*\\!\\s*\\[\\s*CDATA\\s*\\[([^]*)\\]\\]/;\n\nXML.prototype.attribsKey = '_Attribs';\nXML.prototype.dataKey = '_Data';\n\nXML.prototype.parse = function(branch, name) {\n\t// parse text into XML tree, recurse for nested nodes\n\tif (!branch) branch = this.tree;\n\tif (!name) name = null;\n\tvar foundClosing = false;\n\tvar matches = null;\n\t\n\t// match each tag, plus preceding text\n\twhile ( matches = this.patTag.exec(this.text) ) {\n\t\tvar before = matches[1];\n\t\tvar tag = matches[2];\n\t\t\n\t\t// text leading up to tag = content of parent node\n\t\tif (before.match(/\\S/)) {\n\t\t\tif (typeof(branch[this.dataKey]) != 'undefined') branch[this.dataKey] += ' '; else branch[this.dataKey] = '';\n\t\t\tbranch[this.dataKey] += !this.preserveWhitespace ? trim(decode_entities(before)) : decode_entities(before);\n\t\t}\n\t\t\n\t\t// parse based on tag type\n\t\tif (tag.match(this.patSpecialTag)) {\n\t\t\t// special tag\n\t\t\tif (tag.match(this.patPITag)) tag = this.parsePINode(tag);\n\t\t\telse if (tag.match(this.patCommentTag)) tag = this.parseCommentNode(tag);\n\t\t\telse if (tag.match(this.patDTDTag)) tag = this.parseDTDNode(tag);\n\t\t\telse if (tag.match(this.patCDATATag)) {\n\t\t\t\ttag = this.parseCDATANode(tag);\n\t\t\t\tif (typeof(branch[this.dataKey]) != 'undefined') branch[this.dataKey] += ' '; else branch[this.dataKey] = '';\n\t\t\t\tbranch[this.dataKey] += !this.preserveWhitespace ? trim(decode_entities(tag)) : decode_entities(tag);\n\t\t\t} // cdata\n\t\t\telse {\n\t\t\t\tthis.throwParseError( \"Malformed special tag\", tag );\n\t\t\t\tbreak;\n\t\t\t} // error\n\t\t\t\n\t\t\tif (tag == null) break;\n\t\t\tcontinue;\n\t\t} // special tag\n\t\telse {\n\t\t\t// Tag is standard, so parse name and attributes (if any)\n\t\t\tvar matches = tag.match(this.patStandardTag);\n\t\t\tif (!matches) {\n\t\t\t\tthis.throwParseError( \"Malformed tag\", tag );\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\t\n\t\t\tvar closing = matches[1];\n\t\t\tvar nodeName = this.lowerCase ? matches[2].toLowerCase() : matches[2];\n\t\t\tvar attribsRaw = matches[3];\n\t\t\t\n\t\t\t// If this is a closing tag, make sure it matches its opening tag\n\t\t\tif (closing) {\n\t\t\t\tif (nodeName == (name || '')) {\n\t\t\t\t\tfoundClosing = 1;\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tthis.throwParseError( \"Mismatched closing tag (expected </\" + name + \">)\", tag );\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} // closing tag\n\t\t\telse {\n\t\t\t\t// Not a closing tag, so parse attributes into hash.  If tag\n\t\t\t\t// is self-closing, no recursive parsing is needed.\n\t\t\t\tvar selfClosing = !!attribsRaw.match(this.patSelfClosing);\n\t\t\t\tvar leaf = {};\n\t\t\t\tvar attribs = leaf;\n\t\t\t\t\n\t\t\t\t// preserve attributes means they go into a sub-hash named \"_Attribs\"\n\t\t\t\t// the XML composer honors this for restoring the tree back into XML\n\t\t\t\tif (this.preserveAttributes) {\n\t\t\t\t\tleaf[this.attribsKey] = {};\n\t\t\t\t\tattribs = leaf[this.attribsKey];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// parse attributes\n\t\t\t\tthis.patAttrib.lastIndex = 0;\n\t\t\t\twhile ( matches = this.patAttrib.exec(attribsRaw) ) {\n\t\t\t\t\tvar key = this.lowerCase ? matches[1].toLowerCase() : matches[1];\n\t\t\t\t\tattribs[ key ] = decode_entities( matches[3] );\n\t\t\t\t} // foreach attrib\n\t\t\t\t\n\t\t\t\t// if no attribs found, but we created the _Attribs subhash, clean it up now\n\t\t\t\tif (this.preserveAttributes && !num_keys(attribs)) {\n\t\t\t\t\tdelete leaf[this.attribsKey];\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Recurse for nested nodes\n\t\t\t\tif (!selfClosing) {\n\t\t\t\t\tthis.parse( leaf, nodeName );\n\t\t\t\t\tif (this.error()) break;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Compress into simple node if text only\n\t\t\t\tvar num_leaf_keys = num_keys(leaf);\n\t\t\t\tif ((typeof(leaf[this.dataKey]) != 'undefined') && (num_leaf_keys == 1)) {\n\t\t\t\t\tleaf = leaf[this.dataKey];\n\t\t\t\t}\n\t\t\t\telse if (!num_leaf_keys) {\n\t\t\t\t\tleaf = '';\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\t// Add leaf to parent branch\n\t\t\t\tif (typeof(branch[nodeName]) != 'undefined') {\n\t\t\t\t\tif (isa_array(branch[nodeName])) {\n\t\t\t\t\t\tbranch[nodeName].push( leaf );\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tvar temp = branch[nodeName];\n\t\t\t\t\t\tbranch[nodeName] = [ temp, leaf ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\telse if (this.forceArrays && (branch != this.tree)) {\n\t\t\t\t\tbranch[nodeName] = [ leaf ];\n\t\t\t\t}\n\t\t\t\telse {\n\t\t\t\t\tbranch[nodeName] = leaf;\n\t\t\t\t}\n\t\t\t\t\n\t\t\t\tif (this.error() || (branch == this.tree)) break;\n\t\t\t} // not closing\n\t\t} // standard tag\n\t} // main reg exp\n\t\n\t// Make sure we found the closing tag\n\tif (name && !foundClosing) {\n\t\tthis.throwParseError( \"Missing closing tag (expected </\" + name + \">)\", name );\n\t}\n\t\n\t// If we are the master node, finish parsing and setup our doc node\n\tif (branch == this.tree) {\n\t\tif (typeof(this.tree[this.dataKey]) != 'undefined') delete this.tree[this.dataKey];\n\t\t\n\t\tif (num_keys(this.tree) > 1) {\n\t\t\tthis.throwParseError( 'Only one top-level node is allowed in document', first_key(this.tree) );\n\t\t\treturn;\n\t\t}\n\n\t\tthis.documentNodeName = first_key(this.tree);\n\t\tif (this.documentNodeName && !this.preserveDocumentNode) {\n\t\t\tthis.tree = this.tree[this.documentNodeName];\n\t\t}\n\t}\n};\n\nXML.prototype.throwParseError = function(key, tag) {\n\t// log error and locate current line number in source XML document\n\tvar parsedSource = this.text.substring(0, this.patTag.lastIndex);\n\tvar eolMatch = parsedSource.match(/\\n/g);\n\tvar lineNum = (eolMatch ? eolMatch.length : 0) + 1;\n\tlineNum -= tag.match(/\\n/) ? tag.match(/\\n/g).length : 0;\n\t\n\tthis.errors.push({ \n\t\ttype: 'Parse',\n\t\tkey: key,\n\t\ttext: '<' + tag + '>',\n\t\tline: lineNum\n\t});\n\t\n\t// Throw actual error (must wrap parse in try/catch)\n\tthrow new Error( this.getLastError() );\n};\n\nXML.prototype.error = function() {\n\t// return number of errors\n\treturn this.errors.length;\n};\n\nXML.prototype.getError = function(error) {\n\t// get formatted error\n\tvar text = '';\n\tif (!error) return '';\n\n\ttext = (error.type || 'General') + ' Error';\n\tif (error.code) text += ' ' + error.code;\n\ttext += ': ' + error.key;\n\t\n\tif (error.line) text += ' on line ' + error.line;\n\tif (error.text) text += ': ' + error.text;\n\n\treturn text;\n};\n\nXML.prototype.getLastError = function() {\n\t// Get most recently thrown error in plain text format\n\tif (!this.error()) return '';\n\treturn this.getError( this.errors[this.errors.length - 1] );\n};\n\nXML.prototype.parsePINode = function(tag) {\n\t// Parse Processor Instruction Node, e.g. <?xml version=\"1.0\"?>\n\tif (!tag.match(this.patPINode)) {\n\t\tthis.throwParseError( \"Malformed processor instruction\", tag );\n\t\treturn null;\n\t}\n\t\n\tthis.piNodeList.push( tag );\n\treturn tag;\n};\n\nXML.prototype.parseCommentNode = function(tag) {\n\t// Parse Comment Node, e.g. <!-- hello -->\n\tvar matches = null;\n\tthis.patNextClose.lastIndex = this.patTag.lastIndex;\n\t\n\twhile (!tag.match(this.patEndComment)) {\n\t\tif (matches = this.patNextClose.exec(this.text)) {\n\t\t\ttag += '>' + matches[1];\n\t\t}\n\t\telse {\n\t\t\tthis.throwParseError( \"Unclosed comment tag\", tag );\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tthis.patTag.lastIndex = this.patNextClose.lastIndex;\n\treturn tag;\n};\n\nXML.prototype.parseDTDNode = function(tag) {\n\t// Parse Document Type Descriptor Node, e.g. <!DOCTYPE ... >\n\tvar matches = null;\n\t\n\tif (tag.match(this.patExternalDTDNode)) {\n\t\t// tag is external, and thus self-closing\n\t\tthis.dtdNodeList.push( tag );\n\t}\n\telse if (tag.match(this.patInlineDTDNode)) {\n\t\t// Tag is inline, so check for nested nodes.\n\t\tthis.patNextClose.lastIndex = this.patTag.lastIndex;\n\t\t\n\t\twhile (!tag.match(this.patEndDTD)) {\n\t\t\tif (matches = this.patNextClose.exec(this.text)) {\n\t\t\t\ttag += '>' + matches[1];\n\t\t\t}\n\t\t\telse {\n\t\t\t\tthis.throwParseError( \"Unclosed DTD tag\", tag );\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}\n\t\t\n\t\tthis.patTag.lastIndex = this.patNextClose.lastIndex;\n\t\t\n\t\t// Make sure complete tag is well-formed, and push onto DTD stack.\n\t\tif (tag.match(this.patDTDNode)) {\n\t\t\tthis.dtdNodeList.push( tag );\n\t\t}\n\t\telse {\n\t\t\tthis.throwParseError( \"Malformed DTD tag\", tag );\n\t\t\treturn null;\n\t\t}\n\t}\n\telse {\n\t\tthis.throwParseError( \"Malformed DTD tag\", tag );\n\t\treturn null;\n\t}\n\t\n\treturn tag;\n};\n\nXML.prototype.parseCDATANode = function(tag) {\n\t// Parse CDATA Node, e.g. <![CDATA[Brooks & Shields]]>\n\tvar matches = null;\n\tthis.patNextClose.lastIndex = this.patTag.lastIndex;\n\t\n\twhile (!tag.match(this.patEndCDATA)) {\n\t\tif (matches = this.patNextClose.exec(this.text)) {\n\t\t\ttag += '>' + matches[1];\n\t\t}\n\t\telse {\n\t\t\tthis.throwParseError( \"Unclosed CDATA tag\", tag );\n\t\t\treturn null;\n\t\t}\n\t}\n\t\n\tthis.patTag.lastIndex = this.patNextClose.lastIndex;\n\t\n\tif (matches = tag.match(this.patCDATANode)) {\n\t\treturn matches[1];\n\t}\n\telse {\n\t\tthis.throwParseError( \"Malformed CDATA tag\", tag );\n\t\treturn null;\n\t}\n};\n\nXML.prototype.getTree = function() {\n\t// get reference to parsed XML tree\n\treturn this.tree;\n};\n\nXML.prototype.compose = function(indent_string, eol) {\n\t// compose tree back into XML\n\tif (typeof(eol) == 'undefined') eol = \"\\n\";\n\tvar tree = this.tree;\n\tif (this.preserveDocumentNode) tree = tree[this.documentNodeName];\n\t\n\tvar raw = compose_xml( tree, this.documentNodeName, 0, indent_string, eol );\n\tvar body = raw.replace(/^\\s*\\<\\?.+?\\?\\>\\s*/, '');\n\tvar xml = '';\n\t\n\tif (this.piNodeList.length) {\n\t\tfor (var idx = 0, len = this.piNodeList.length; idx < len; idx++) {\n\t\t\txml += '<' + this.piNodeList[idx] + '>' + eol;\n\t\t}\n\t}\n\telse {\n\t\txml += xml_header + eol;\n\t}\n\t\n\tif (this.dtdNodeList.length) {\n\t\tfor (var idx = 0, len = this.dtdNodeList.length; idx < len; idx++) {\n\t\t\txml += '<' + this.dtdNodeList[idx] + '>' + eol;\n\t\t}\n\t}\n\t\n\txml += body;\n\treturn xml;\n};\n\n//\n// Static Utility Functions:\n//\n\nvar parse_xml = exports.parse = function parse_xml(text, opts) {\n\t// turn text into XML tree quickly\n\tif (!opts) opts = {};\n\topts.text = text;\n\tvar parser = new XML(opts);\n\treturn parser.error() ? parser.getLastError() : parser.getTree();\n};\n\nvar trim = exports.trim = function trim(text) {\n\t// strip whitespace from beginning and end of string\n\tif (text == null) return '';\n\t\n\tif (text && text.replace) {\n\t\ttext = text.replace(/^\\s+/, \"\");\n\t\ttext = text.replace(/\\s+$/, \"\");\n\t}\n\t\n\treturn text;\n};\n\nvar encode_entities = exports.encodeEntities = function encode_entities(text) {\n\t// Simple entitize exports.for = function for composing XML\n\tif (text == null) return '';\n\t\n\tif (text && text.replace) {\n\t\ttext = text.replace(/\\&/g, \"&amp;\"); // MUST BE FIRST\n\t\ttext = text.replace(/</g, \"&lt;\");\n\t\ttext = text.replace(/>/g, \"&gt;\");\n\t}\n\t\n\treturn text;\n};\n\nvar encode_attrib_entities = exports.encodeAttribEntities = function encode_attrib_entities(text) {\n\t// Simple entitize exports.for = function for composing XML attributes\n\tif (text == null) return '';\n\t\n\tif (text && text.replace) {\n\t\ttext = text.replace(/\\&/g, \"&amp;\"); // MUST BE FIRST\n\t\ttext = text.replace(/</g, \"&lt;\");\n\t\ttext = text.replace(/>/g, \"&gt;\");\n\t\ttext = text.replace(/\\\"/g, \"&quot;\");\n\t\ttext = text.replace(/\\'/g, \"&apos;\");\n\t}\n\t\n\treturn text;\n};\n\nvar decode_entities = exports.decodeEntities = function decode_entities(text) {\n\t// Decode XML entities into raw ASCII\n\tif (text == null) return '';\n\t\n\tif (text && text.replace && text.match(/\\&/)) {\n\t\ttext = text.replace(/\\&lt\\;/g, \"<\");\n\t\ttext = text.replace(/\\&gt\\;/g, \">\");\n\t\ttext = text.replace(/\\&quot\\;/g, '\"');\n\t\ttext = text.replace(/\\&apos\\;/g, \"'\");\n\t\ttext = text.replace(/\\&amp\\;/g, \"&\"); // MUST BE LAST\n\t}\n\t\n\treturn text;\n};\n\nvar compose_xml = exports.stringify = function compose_xml(node, name, indent, indent_string, eol, sort) {\n\t// Compose node into XML including attributes\n\t// Recurse for child nodes\n\tif (typeof(indent_string) == 'undefined') indent_string = \"\\t\";\n\tif (typeof(eol) == 'undefined') eol = \"\\n\";\n\tif (typeof(sort) == 'undefined') sort = true;\n\tvar xml = \"\";\n\t\n\t// If this is the root node, set the indent to 0\n\t// and setup the XML header (PI node)\n\tif (!indent) {\n\t\tindent = 0;\n\t\txml = xml_header + eol;\n\t\t\n\t\tif (!name) {\n\t\t\t// no name provided, assume content is wrapped in it\n\t\t\tname = first_key(node);\n\t\t\tnode = node[name];\n\t\t}\n\t}\n\t\n\t// Setup the indent text\n\tvar indent_text = \"\";\n\tfor (var k = 0; k < indent; k++) indent_text += indent_string;\n\t\n\tif ((typeof(node) == 'object') && (node != null)) {\n\t\t// node is object -- now see if it is an array or hash\n\t\tif (!node.length) { // what about zero-length array?\n\t\t\t// node is hash\n\t\t\txml += indent_text + \"<\" + name;\n\t\t\t\n\t\t\tvar num_keys = 0;\n\t\t\tvar has_attribs = 0;\n\t\t\tfor (var key in node) num_keys++; // there must be a better way...\n\t\t\t\n\t\t\tif (node[\"_Attribs\"]) {\n\t\t\t\thas_attribs = 1;\n\t\t\t\tvar sorted_keys = sort ? hash_keys_to_array(node[\"_Attribs\"]).sort() : hash_keys_to_array(node[\"_Attribs\"]);\n\t\t\t\tfor (var idx = 0, len = sorted_keys.length; idx < len; idx++) {\n\t\t\t\t\tvar key = sorted_keys[idx];\n\t\t\t\t\txml += \" \" + key + \"=\\\"\" + encode_attrib_entities(node[\"_Attribs\"][key]) + \"\\\"\";\n\t\t\t\t}\n\t\t\t} // has attribs\n\t\t\t\n\t\t\tif (num_keys > has_attribs) {\n\t\t\t\t// has child elements\n\t\t\t\txml += \">\";\n\t\t\t\t\n\t\t\t\tif (node[\"_Data\"]) {\n\t\t\t\t\t// simple text child node\n\t\t\t\t\txml += encode_entities(node[\"_Data\"]) + \"</\" + name + \">\" + eol;\n\t\t\t\t} // just text\n\t\t\t\telse {\n\t\t\t\t\txml += eol;\n\t\t\t\t\t\n\t\t\t\t\tvar sorted_keys = sort ? hash_keys_to_array(node).sort() : hash_keys_to_array(node);\n\t\t\t\t\tfor (var idx = 0, len = sorted_keys.length; idx < len; idx++) {\n\t\t\t\t\t\tvar key = sorted_keys[idx];\t\t\t\t\t\n\t\t\t\t\t\tif ((key != \"_Attribs\") && key.match(re_valid_tag_name)) {\n\t\t\t\t\t\t\t// recurse for node, with incremented indent value\n\t\t\t\t\t\t\txml += compose_xml( node[key], key, indent + 1, indent_string, eol, sort );\n\t\t\t\t\t\t} // not _Attribs key\n\t\t\t\t\t} // foreach key\n\t\t\t\t\t\n\t\t\t\t\txml += indent_text + \"</\" + name + \">\" + eol;\n\t\t\t\t} // real children\n\t\t\t}\n\t\t\telse {\n\t\t\t\t// no child elements, so self-close\n\t\t\t\txml += \"/>\" + eol;\n\t\t\t}\n\t\t} // standard node\n\t\telse {\n\t\t\t// node is array\n\t\t\tfor (var idx = 0; idx < node.length; idx++) {\n\t\t\t\t// recurse for node in array with same indent\n\t\t\t\txml += compose_xml( node[idx], name, indent, indent_string, eol, sort );\n\t\t\t}\n\t\t} // array of nodes\n\t} // complex node\n\telse {\n\t\t// node is simple string\n\t\txml += indent_text + \"<\" + name + \">\" + encode_entities(node) + \"</\" + name + \">\" + eol;\n\t} // simple text node\n\t\n\treturn xml;\n};\n\nvar always_array = exports.alwaysArray = function always_array(obj, key) {\n\t// if object is not array, return array containing object\n\t// if key is passed, work like XMLalwaysarray() instead\n\tif (key) {\n\t\tif ((typeof(obj[key]) != 'object') || (typeof(obj[key].length) == 'undefined')) {\n\t\t\tvar temp = obj[key];\n\t\t\tdelete obj[key];\n\t\t\tobj[key] = new Array();\n\t\t\tobj[key][0] = temp;\n\t\t}\n\t\treturn null;\n\t}\n\telse {\n\t\tif ((typeof(obj) != 'object') || (typeof(obj.length) == 'undefined')) { return [ obj ]; }\n\t\telse return obj;\n\t}\n};\n\nvar hash_keys_to_array = exports.hashKeysToArray = function hash_keys_to_array(hash) {\n\t// convert hash keys to array (discard values)\n\tvar array = [];\n\tfor (var key in hash) array.push(key);\n\treturn array;\n};\n\nvar isa_array = exports.isaArray = function isa_array(arg) {\n\t// determine if arg is an array or is array-like\n\treturn isArray(arg);\n};\n\nvar isa_hash = exports.isaHash = function isa_hash(arg) {\n\t// determine if arg is a hash\n\treturn( !!arg && (typeof(arg) == 'object') && !isa_array(arg) );\n};\n\nvar first_key = exports.firstKey = function first_key(hash) {\n\t// return first key from hash (unordered)\n\tfor (var key in hash) return key;\n\treturn null; // no keys in hash\n};\n\nvar num_keys = exports.numKeys = function num_keys(hash) {\n\t// count the number of keys in a hash\n\tvar count = 0;\n\tfor (var a in hash) count++;\n\treturn count;\n};\n"]}