Currently treats ALL data as a DOMString (i.e. no Document)
195518
function send(data) {
                verifyState(this);

                if (!/^(get|head)$/i.test(this.method)) {
                    var contentType = getHeader(this.requestHeaders, "Content-Type");
                    if (this.requestHeaders[contentType]) {
                        var value = this.requestHeaders[contentType].split(";");
                        this.requestHeaders[contentType] = value[0] + ";charset=utf-8";
                    } else if (!(data instanceof FormData)) {
                        this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8";
                    }

                    this.requestBody = data;
                }

                this.errorFlag = false;
                this.sendFlag = this.async;
                this.readyStateChange(FakeXMLHttpRequest.OPENED);

                if (typeof this.onSend == "function") {
                    this.onSend(this);
                }

                this.dispatchEvent(new sinon.Event("loadstart", false, false, this));
            }
238685
function _dumpDOM(root) {
        var result = "",
            indent = "";

        function walk(node) {
            if (node.tag) {
                result += indent + "TAG " + node.tagID + " " + node.tag + " " + JSON.stringify(node.attributes) + "\n";
            } else {
                result += indent + "TEXT " + (node.tagID || "- ") + node.content + "\n";
            }
            if (node.isElement()) {
                indent += "  ";
                node.children.forEach(walk);
                indent = indent.slice(2);
            }
        }
        walk(root);

        return result;
    }
1331725
function cleanUpData(data) {
  if (!(data instanceof Tag) && !(data && typeof data.trigger == T_FUNCTION))
    return data

  var o = {}
  for (var key in data) {
    if (!contains(RESERVED_WORDS_BLACKLIST, key))
      o[key] = data[key]
  }
  return o
}
4120
function(el, name) {
  var readAll = arguments.length === 1;
  var domNames, domName, jsNames, jsName, value, idx, length;

  if (readAll) {
    domNames = Object.keys(el.attribs).filter(function(attrName) {
      return attrName.slice(0, dataAttrPrefix.length) === dataAttrPrefix;
    });
    jsNames = domNames.map(function(_domName) {
      return camelCase(_domName.slice(dataAttrPrefix.length));
    });
  } else {
    domNames = [dataAttrPrefix + cssCase(name)];
    jsNames = [name];
  }

  for (idx = 0, length = domNames.length; idx < length; ++idx) {
    domName = domNames[idx];
    jsName = jsNames[idx];
    if (hasOwn.call(el.attribs, domName)) {
      value = el.attribs[domName];

      if (hasOwn.call(primitives, value)) {
        value = primitives[value];
      } else if (value === String(Number(value))) {
        value = Number(value);
      } else if (rbrace.test(value)) {
        try {
          value = JSON.parse(value);
        } catch(e){ }
      }

      el.data[jsName] = value;
    }
  }

  return readAll ? el.data : value;
}
715323
public static String docToString1(Document dom) {
        StringWriter sw = new StringWriter();
        DOM2Writer.serializeAsXML(dom, sw);
        return sw.toString();
    }
691944
function data(element) {
            var options = {}
            Util.each(element.attributes, function(attribute) {
                var ma = /data-(.+)/.exec(attribute.name)
                if (!ma) return

                var value = attribute.value
                try {
                    /* jshint evil:true */
                    options[ma[1]] = /^\s*[\[{]/.test(value) ?
                        eval('(function(){ return Array.prototype.slice.call(arguments)[0] })(' + value + ')') :
                        value
                } catch (error) {
                    options[ma[1]] = value
                }

                if (options[ma[1]] === 'true') options[ma[1]] = true
                if (options[ma[1]] === 'false') options[ma[1]] = false
            })
            return options
        }
989199
function dom (tree, node, data) {
  let findElseBranch = false
  let logical = false

  function getValue (data, info, str) {
    if (!EQ_RE.test(str)) return str
    let exp = str.replace(EQ_RE, '')
    if (FMT_RE.test(exp)) exp = '__format(' + exp + ')'
    logical = true
    const value = common.scopedExpression(data, info, exp)
    return value // he.escape(value + '')
  }

  function compile (child, index) {
    // if (child.dom) return node.appendChild(child.dom)
    const locationData = { pos: child.pos || {}, location }

    // if (child.unescaped) {
    //  child.content = he.escape(child.content)
    // }

    const firstLetter = child.tagOrSymbol.charCodeAt(0)

    //
    // first handle any flow control statements
    //
    if (child.tagOrSymbol === 'else') {
      if (!findElseBranch) return

      logical = true
      // if this is an else-if
      if (IF_RE.test(child.content)) {
        const exp = child.content.replace(IF_RE, '')
        if (common.scopedExpression(data, locationData, exp)) {
          findElseBranch = false
          const branch = document.createDocumentFragment()
          const children = dom(child, branch, data)
          if (children) node.appendChild(branch)
        }
        return
      }

      findElseBranch = false
      const branch = document.createDocumentFragment()
      const children = dom(child, branch, data)
      if (children) node.appendChild(branch)
      return
    }

    if (child.tagOrSymbol === 'comment') {
      const comment = document.createComment(child.content)
      node.appendChild(comment)
      return
    }

    if (child.tagOrSymbol === 'if') {
      logical = true
      if (common.scopedExpression(data, locationData, child.content)) {
        const branch = document.createDocumentFragment()
        const children = dom(child, branch, data)
        if (children) node.appendChild(branch)
        return
      }
      findElseBranch = true
      return
    }

    if (child.tagOrSymbol === 'while') {
      logical = true
      while (common.scopedExpression(data, locationData, child.content)) {
        const children = dom(child, node, data)
        if (children) node.appendChild(children)
      }
      return
    }

    if (child.tagOrSymbol === 'for') {
      logical = true

      const parts = child.content.split(IN_RE)
      if (!parts[0]) common.die(locationData, 'TypeError', 'Unknown mixin')

      const object = common.scopedExpression(data, locationData, parts[1])

      common.each(object, function (val, key) {
        // determine if there are identifiers for key and value
        const identifiers = parts[0].split(',')
        const keyIdentifier = identifiers[0]
        const valIdentifier = identifiers[1]
        const locals = { [keyIdentifier]: key }

        if (valIdentifier) {
          locals[valIdentifier] = val
        }
        // create a new shallow scope so that locals don't persist
        const scope = Object.assign({}, data, locals)
        const children = dom(child, node, scope)
        if (children) node.appendChild(children)
      })
      return
    }

    if (child.tagOrSymbol === 'each') {
      common.die(locationData, 'TypeError', 'Each not supported (use for)')
    }

    // treat all piped text as plain content
    if (child.tagOrSymbol === '|') {
      return (node.textContent += getValue(data, locationData, child.content))
    }

    if (firstLetter === HYPHEN) {
      common.die(locationData, 'Error', 'No inline code!')
    }

    /* if (firstLetter === COLON && cb) {
      logical = true
      const name = 'jstransformer-' + child.tagOrSymbol.slice(1)
      let t = null
      try {
        t = transformer(require(name))
      } catch (ex) {
        common.die(child.pos, 'Error', fmt('%s not installed', name))
      }
      const path = child.content
      const data = cb({ path, location })
      const parsed = t.render(data.tree, child.attributes)
      node.textContent += parsed.body
      return
    }

    // anything prefixed with '+' is a mixin call.
    if (firstLetter === PLUS && cb) {
      logical = true
      const name = child.tagOrSymbol.slice(1)
      if (!cache[name]) {
        common.die(child.pos, 'TypeError', 'Unknown mixin')
      }

      const locals = {}
      const args = Object.keys(child.attributes).map(attr => {
        return common.scopedExpression(data, child.pos, attr)
      })

      cache[name].keys.map((k, index) => (locals[k] = args[index]))
      const scope = Object.assign({}, data, locals)
      const children = dom(cache[name].child, node, scope)
      node.appendChild(children)
      return
    } */

    // defines a mixin
    if (firstLetter >= A && firstLetter <= Z) {
      logical = true
      const keys = Object.keys(child.attributes)
      cache[child.tagOrSymbol] = { child, keys }
      return
    }

    //
    // everything else is a tag
    //
    const props = common.resolveTagOrSymbol(child.tagOrSymbol)

    let el = document.createElement(props.tagname)

    if (props.id) el.id = props.id
    if (props.classname) el.className = props.classname

    if (child.attributes) {
      Object.keys(child.attributes).map(key => {
        let value = child.attributes[key]

        // if this attribute is a boolean, make its value its key
        if (typeof value === 'boolean') {
          el.setAttribute(key, key)
        }

        if (value) {
          // all values are expressions
          value = common.scopedExpression(data, locationData, value)
          // a class should not be empty
          if (key === 'class' && !value) return

          // data-* attributes should be escaped
          if (key.indexOf('data-') === 0) {
            if (typeof value !== 'string' && typeof value !== 'number') {
              value = JSON.stringify(value)
            }
          }
        }
        el.setAttribute(key, value)
      })
    }

    if (child.content) {
      el.textContent = (child.tagOrSymbol === 'script')
        ? child.content
        : getValue(data, locationData, child.content)
    }

    // nothing left to decide, recurse if there are child nodes
    if (child.children.length) {
      const children = dom(child, el, data)
      if (children) node.appendChild(children)
    }

    // if this is not a logical node, we can make an optimization
    // if (!logical) child.dom = el
    node.appendChild(el)
  }

  if (tree.children && tree.children.length) {
    tree.children.map(compile)
  }
  return node
}
531751
function (dom) {
            var html = '';
            dom.forEach(function (node) {
                if (node.type === 'tag') {
                    var tag = node.name;
                    html += '<' + tag;
                    Object.keys(node.attribs).forEach(function (attr) {
                        html += ' ' + attr + '=' + this.generateAttribute(node.attribs[attr]);
                    }, this);
                    html += (voidTags[tag] ? '/>' : '>');
                    if (!voidTags[tag]) {
                        html += this.vdomToHtml(node.children);
                        html += '</' + tag + '>';
                    }
                } else if (node.type === 'text') {
                    var text = node.data || '';
                    html += this.htmlEncode(text); //escape <,> and &.
                } else if (node.type === 'comment') {
                    html += '<!-- ' + node.data.trim() + ' -->';
                } else if (node.type === 'script' || node.type === 'style') {
                    //No need to escape text inside script or style tag.
                    html += '<' + node.name;
                    Object.keys(node.attribs).forEach(function (attr) {
                        html += ' ' + attr + '=' + this.generateAttribute(node.attribs[attr]);
                    }, this);
                    html += '>' + ((node.children[0] || {}).data || '') + '</' + node.name + '>';
                } else if (node.type === 'directive') {
                    html += '<' + node.data + '>';
                }
            }, this);
            return html;
        }
1083868
private void convertOldDocument() {

        Document newDocument = DocumentHelper.createDocument();
        Element root = newDocument.addElement(NODE_PAGES);
        root.add(I_CmsXmlSchemaType.XSI_NAMESPACE);
        root.addAttribute(I_CmsXmlSchemaType.XSI_NAMESPACE_ATTRIBUTE_NO_SCHEMA_LOCATION, XMLPAGE_XSD_SYSTEM_ID);

        Map<String, Element> pages = new HashMap<String, Element>();

        if ((m_document.getRootElement() != null) && (m_document.getRootElement().element(NODE_ELEMENTS) != null)) {
            for (Iterator<Element> i = CmsXmlGenericWrapper.elementIterator(
                m_document.getRootElement().element(NODE_ELEMENTS),
                NODE_ELEMENT); i.hasNext();) {

                Element elem = i.next();
                try {
                    String elementName = elem.attributeValue(ATTRIBUTE_NAME);
                    String elementLang = elem.attributeValue(ATTRIBUTE_LANGUAGE);
                    String elementEnabled = elem.attributeValue(ATTRIBUTE_ENABLED);
                    boolean enabled = (elementEnabled == null) ? true : Boolean.valueOf(elementEnabled).booleanValue();

                    Element page = pages.get(elementLang);
                    if (page == null) {
                        // no page available for the language, add one
                        page = root.addElement(NODE_PAGE).addAttribute(ATTRIBUTE_LANGUAGE, elementLang);
                        pages.put(elementLang, page);
                    }

                    Element newElement = page.addElement(NODE_ELEMENT).addAttribute(ATTRIBUTE_NAME, elementName);
                    if (!enabled) {
                        newElement.addAttribute(ATTRIBUTE_ENABLED, String.valueOf(enabled));
                    }
                    Element links = elem.element(NODE_LINKS);
                    if (links != null) {
                        newElement.add(links.createCopy());
                    }
                    Element content = elem.element(NODE_CONTENT);
                    if (content != null) {
                        newElement.add(content.createCopy());
                    }

                } catch (NullPointerException e) {
                    LOG.error(Messages.get().getBundle().key(Messages.ERR_XML_PAGE_CONVERT_CONTENT_0), e);
                }
            }
        }

        // now replace the old with the new document
        m_document = newDocument;
    }
984834
function parser(el, attr) {
	// empty input fallback to empty text node
	if (!el) {
		return createNode(document.createTextNode(''));
	}

	if (typeof el === 'string') {
		if ( !('DOMParser' in window) ) {
			throw new Error('DOMParser is not available, so parsing string to DOM node is not possible.');
		}
		domParser = domParser || new DOMParser();
		var doc = domParser.parseFromString(el, 'text/html');

		// most tags default to body
		if (doc.body.firstChild) {
			el = doc.getElementsByTagName('body')[0].firstChild;

		// some tags, like script and style, default to head
		} else if (doc.head.firstChild && (doc.head.firstChild.tagName !== 'TITLE' || doc.title)) {
			el = doc.head.firstChild;

		// special case for html comment, cdata, doctype
		} else if (doc.firstChild && doc.firstChild.tagName !== 'HTML') {
			el = doc.firstChild;

		// other element, such as whitespace, or html/body/head tag, fallback to empty text node
		} else {
			el = document.createTextNode('');
		}
	}

	if (typeof el !== 'object' || !el || !el.nodeType) {
		throw new Error('invalid dom node', el);
	}

	return createNode(el, attr);
}
1083504
function(d) {
		// update data
		this.data = TL.Util.mergeData(this.data, d);
		
		// Title
		this._el.title.innerHTML = TL.Util.unlinkify(this.data.title);
		
		// Date
		this._el.description.innerHTML	= TL.Util.unlinkify(this.data.date);
	}
1351300
def handle_data(self, data):
        """"""
        # Only process the data when we are in an active a tag and have an URL.
        if not self.active_url:
            return

        # The visible text can have a final slash so strip it off
        if data.strip('/') == self.active_url:
            self.entries.append(self.active_url)
732280
def _to_DOM(self):
        
        root_node = ET.Element('station')
        created_at_node = ET.SubElement(root_node, "created_at")
        created_at_node.text = \
            timeformatutils.to_ISO8601(self.created_at)if self.created_at is not None else 'null'
        updated_at_node = ET.SubElement(root_node, "updated_at")
        updated_at_node.text = \
            timeformatutils.to_ISO8601(self.updated_at)if self.updated_at is not None else 'null'
        station_id_node = ET.SubElement(root_node, 'id')
        station_id_node.text = str(self.id)
        station_id_node = ET.SubElement(root_node, 'external_id')
        station_id_node.text = str(self.external_id)
        station_name_node = ET.SubElement(root_node, 'name')
        station_name_node.text = str(self.name) if self.name is not None else 'null'
        lat_node = ET.SubElement(root_node, 'lat')
        lat_node.text = str(self.lat)
        lon_node = ET.SubElement(root_node, 'lon')
        lon_node.text = str(self.lon)
        alt_node = ET.SubElement(root_node, 'alt')
        alt_node.text = str(self.alt) if self.alt is not None else 'null'
        rank_node = ET.SubElement(root_node, 'rank')
        rank_node.text = str(self.rank) if self.rank is not None else 'null'

        return root_node
316404
def _fix_data_select(self):
        

        elements = self.document.select('*')
        for element in elements:
            attributes = element.attrs.keys()
            data_attributes = list()
            for attribute in attributes:
                if bool(re.findall('^data-', attribute)):
                    data_attributes.append({
                        'original': attribute,
                        'modified': re.sub('data-', 'dataaaaaa', attribute),
                        'value': element[attribute]
                    })
            if data_attributes:
                auxiliar_element = BeautifulSoupHTMLDOMElement(element)
                for data_attribute in data_attributes:
                    auxiliar_element.remove_attribute(
                        data_attribute['original']
                    )
                    auxiliar_element.set_attribute(
                        data_attribute['modified'],
                        data_attribute['value']
                    )
36004
private Document parse(final String data) {
    if (docBuilder == null || data == null) {
      return null;
    }

    Document document = null;

    try {
      // we change the system ID to a valid URI so that Crimson won't
      // complain. Indeed, "log4j.dtd" alone is not a valid URI which
      // causes Crimson to barf. The Log4jEntityResolver only cares
      // about the "log4j.dtd" ending.

      /**
       * resetting the length of the StringBuffer is dangerous, particularly
       * on some JDK 1.4 impls, there's a known Bug that causes a memory leak
       */
      StringBuffer buf = new StringBuffer(1024);

      if (!data.startsWith("<?xml")) {
        buf.append(BEGIN_PART);
      }

      buf.append(data);

      if (!data.endsWith(END_PART)) {
        buf.append(END_PART);
      }

      InputSource inputSource =
        new InputSource(new StringReader(buf.toString()));
      document = docBuilder.parse(inputSource);
    } catch (Exception e) {
      e.printStackTrace();
    }

    return document;
  }
684214
def emptyElement(self, name, attrs):
        """"""
        attr = ' '.join('%s=%s' % (n, quoteattr(scientificformat(v)))
                        for n, v in sorted(attrs.items()))
        self._write('<%s %s/>' % (name, attr))
740820
def clean_html(data, full=True, parser=DEFAULT_PARSER):
    
    if full:
        dom_tree = parser.parse(data)
    else:
        dom_tree = parser.parseFragment(data)
    walker = treewalkers.getTreeWalker('dom')
    kwargs = _filter_kwargs()
    stream = TextSanitizer(walker(dom_tree), **kwargs)
    s = serializer.HTMLSerializer(
        omit_optional_tags=False,
        quote_attr_values='always',
    )
    return u''.join(s.serialize(stream))