TODO rootnode recording of result is sutbly different - the rootnode is just the sum of its parts, but features can be tagged with non fatal tags
423046
@Override
    protected void recordResult(final RootNode node, final boolean success, final RootNodeExecutionContext context) {

        if (success) {
            if (log.isTraceEnabled()) {

                log.trace("node success");
            }

            node.getResult().setFinished();
            context.getNotificationDistributor().onNodeFinished(node);

        } else {

            final List<SubstepExecutionFailure> failures = context.getFailures();

            if (log.isDebugEnabled()) {

                log.debug("node failures");
            }

            // have a look at the constituent features
            List<FeatureNode> featureNodes = node.getChildren();
            boolean rootNodeStateSet = false;
            for (FeatureNode featureNode : node.getChildren()){

                if(featureNode.getResult().getResult() == ExecutionResult.FAILED && !featureNode.getResult().getFailure().isNonCritical()){
                    // we've got one valid feature failure, fail the root node
                    SubstepsRuntimeException e = new SubstepsRuntimeException("At least one critical Feature failed");
                    SubstepExecutionFailure sef = new SubstepExecutionFailure(e, node, ExecutionResult.FAILED);

                    context.getNotificationDistributor().onNodeFailed(node, e);
                    rootNodeStateSet = true;
                    break;
                }
            }

            if (!rootNodeStateSet){
                // got this far, must be ok
                node.getResult().setFinished();
                context.getNotificationDistributor().onNodeFinished(node);
            }


//            final Throwable lastException;
//            boolean nonCritical = false;
//            if (!failures.isEmpty()) {
//
//                final SubstepExecutionFailure lastFailure = failures.get(failures.size() - 1);
//                // just notify on the last one in..?
//                lastException = lastFailure.getCause();
//                node.getResult().setScreenshot(lastFailure.getScreenshot());
//                nonCritical = lastFailure.isNonCritical();
//            }
//            else {
//                lastException = new SubstepsRuntimeException("Error throw during startup, initialisation issue ?");
//                lastException.fillInStackTrace();
//                SubstepExecutionFailure sef = new SubstepExecutionFailure(lastException, node, ExecutionResult.FAILED);
//            }



//            SubstepExecutionFailure sef = new SubstepExecutionFailure(lastException, node, ExecutionResult.FAILED);
//            sef.setNonCritical(nonCritical);
//            context.getNotificationDistributor().onNodeFailed(node, lastException);

        }
    }
816771
function normalizeNode() {
    $this->node = '<';
    if (!$this->isStartTag) {
      $this->node .= '/'.$this->tagName.'>';
      return;
    }
    $this->node .= $this->tagName;
    foreach ($this->tagAttributes as $name => $value) {
      $this->node .= ' '.$name.'="'.str_replace('"', '&quot;', $value).'"';
    }
    if ($this->isEmptyTag) {
      $this->node .= ' /';
    }
    $this->node .= '>';
  }
776312
function processNode(node) {
    if (node.tagName === 'P' || node.tagName === 'DIV' || node.tagName === 'UL' || node.tagName === 'OL' || node.tagName === 'PRE')
      setContent(node, getContent(node), '\n\n', '\n\n');
    else if (node.tagName === 'BR')
      setContent(node, '\n\n');
    else if (node.tagName === 'HR')
      setContent(node, '\n***\n');
    else if (node.tagName === 'H1')
      setContent(node, nltrim(getContent(node)), '\n# ', '\n');
    else if (node.tagName === 'H2') 
      setContent(node, nltrim(getContent(node)), '\n## ', '\n');
    else if (node.tagName === 'H3')
      setContent(node, nltrim(getContent(node)), '\n### ', '\n');
    else if (node.tagName === 'H4') 
      setContent(node, nltrim(getContent(node)), '\n#### ', '\n');
    else if (node.tagName === 'H5') 
      setContent(node, nltrim(getContent(node)), '\n##### ', '\n');
    else if (node.tagName === 'H6')
      setContent(node, nltrim(getContent(node)), '\n###### ', '\n');
    else if (node.tagName === 'B' || node.tagName === 'STRONG')
      setContent(node, nltrim(getContent(node)), '**', '**');
    else if (node.tagName === 'I' || node.tagName === 'EM')
      setContent(node, nltrim(getContent(node)), '_', '_');
    else if (node.tagName === 'A') {
      var href = node.href ? nltrim(node.href) : '', text = nltrim(getContent(node)) || href, title = node.title ? nltrim(node.title) : '';
      if (href.length > 0)
        setContent(node, '[' + text + '](' + href + (title ? ' "' + title + '"' : '') + ')');
      else
        setContent(node, '');
    } else if (node.tagName === 'IMG') {
      var src = node.getAttribute('src') ? nltrim(node.getAttribute('src')) : '', alt = node.alt ? nltrim(node.alt) : '', caption = node.title ? nltrim(node.title) : '';
      if (src.length > 0)
        setContent(node, '![' + alt + '](' + src  + (caption ? ' "' + caption + '"' : '') + ')');
      else
        setContent(node, '');
    } else if (node.tagName === 'BLOCKQUOTE') {
      var block_content = getContent(node);
      if (block_content.length > 0)
        setContent(node, prefixBlock('> ', block_content), '\n\n', '\n\n');
      else
        setContent(node, '');
    } else if (node.tagName === 'CODE') {
      if (node._bfs_parent.tagName === 'PRE' && node._bfs_parent._bfs_parent !== null)
        setContent(node, prefixBlock('    ', getContent(node)));
      else
        setContent(node, nltrim(getContent(node)), '`', '`');
    } else if (node.tagName === 'LI') {
      var list_content = getContent(node);
      if (list_content.length > 0)
        if (node._bfs_parent.tagName === 'OL') 
          setContent(node, trim(prefixBlock('    ', list_content, true)), '1. ', '\n\n');
        else
          setContent(node, trim(prefixBlock('    ', list_content, true)), '- ', '\n\n');
      else
        setContent(node, '');
    } else 
      setContent(node, getContent(node));
  }
7357
def encode(self):
        
        root_element = ElementTree.Element(self.TAG_NAME)
        for value in [value for value in self.__dict__.values() if isinstance(value, fields.Field)]:
            if value.required or value.value:
                root_element.append(value.encode())
        return root_element
1007220
private Node getNode(Node nodeStart, String key, CreateMode createMode, boolean bReturnTextNode)
    {
        if (key.indexOf('/') != -1)
        {
            String strKeyParent = key.substring(0, key.indexOf('/'));
            CreateMode createModeParent = createMode;
            if (createModeParent == CreateMode.CREATE_NEW_NODE)
                createModeParent = CreateMode.CREATE_IF_NOT_FOUND;  // Only create a duplicate node at the leaf level.
            nodeStart = this.getNode(nodeStart, strKeyParent, createModeParent, false);
            if (nodeStart == null)
                return null;
            key = key.substring(key.indexOf('/') + 1);
            return this.getNode(nodeStart, key, createMode, bReturnTextNode);
        }
        if (nodeStart == null)
            nodeStart = this.getNode(true);

        int iIndex = Integer.MAX_VALUE;
        if (key.indexOf('[') != -1)
        {
            iIndex = Integer.parseInt(key.substring(key.indexOf('[') + 1, key.indexOf(']')));
            key = key.substring(0, key.indexOf('['));
        }
        key = Util.fixDOMElementName(key);
        Node node = null;
        NodeList nodeList = ((Element)nodeStart).getElementsByTagName(key);
        if (nodeList != null)
        {
            for (int i = 0; i < nodeList.getLength(); i++)
            {
                if (nodeList.item(i).getParentNode() == nodeStart)
                {
                    node = nodeList.item(i);    // Get the last child.
                    if (iIndex != Integer.MAX_VALUE)
                    {
                        if (--iIndex == 0)
                            break;  // This is the correct node
                        node = null;    // If you are looking for a specific node, and it doesn't exist, return null.
                    }
                }
            }
        }
        if (((node == null) && (createMode != CreateMode.DONT_CREATE))
                || (createMode == CreateMode.CREATE_NEW_NODE))
        {
        	Document doc = null;
        	if (m_data instanceof Document)
        		doc = (Document)m_data;
        	if (doc == null)
        		doc = ((Node)m_data).getOwnerDocument();
            node = doc.createElement(key);
            if (bReturnTextNode)
            {
                if (createMode != CreateMode.CREATE_CDATA_NODE)
                    node.appendChild(doc.createTextNode(Constant.BLANK));
                else
                    node.appendChild(doc.createCDATASection(Constant.BLANK));
            }
            nodeStart.appendChild(node);
        }
        if (node != null)
            if (bReturnTextNode)
                node = node.getFirstChild();
        return node;    // Return new node or null.
    }
1100403
def roots(self):
        
        if not self.is_tagged(ANALYSIS):
            self.tag_analysis()
        return self.get_analysis_element(ROOT)
504606
function(_root,_umi,_hanlder){
        var _node = _root,
            _hanlder = _hanlder||_f;
        if (_umi!='/'){
            _u._$forEach(
                _umi.split('/'),function(_name){
                    var _result = _hanlder(_node,_name);
                    if (!_result) 
                        return !0;
                    _node = _result;
                }
            );
        }
        return _node;
    }
617958
private Node getNodeToBeReplaced(Node parametersNode) {
        Node toBeReplaced = null;
        int responseCount = 0;
        NodeList childNodes = parametersNode.getChildNodes();
        if (childNodes != null) {
            for (int j = 0; j < childNodes.getLength(); j++) {
                Node childNode = childNodes.item(j);
                String name=childNode.getLocalName();
                if ("simpleResponse".equals(name) || "response".equals(name)) {
                    responseCount++;
                    if("response".equals(name)){
                        //This is the node that will need to be replaced with a copy with a localName of "simpleResponse"
                        toBeReplaced=childNode;
                    }
                }
                //If responseCount>1 This implies that both a simpleResponse and response have
                //been defined - this is allowed by the xsd, but makes no sense
                if (responseCount > 1) {
                    throw new IllegalArgumentException("Only one of either simpleResponse or response should define the response type");
                }
            }
        }
        return toBeReplaced;
    }
140529
function truncateNestedNodeStart($element, $rootNode, $clipNode, options) {
    var element = $element[0];

    var $children = $element.contents();
    var $child, child;

    var length = $children.length;
    var index = length -1;
    var truncated = false;

    $element.empty();

    for (; index >= 0 && !truncated; index--) {

      $child = $children.eq(index);
      child = $child[0];

      if (child.nodeType === 8) { // comment node
        continue;
      }

      element.insertBefore(child, element.firstChild);

      if ($clipNode.length) {
        if ($.inArray(element.tagName.toLowerCase(), BLOCK_TAGS) >= 0) {
          // Certain elements like <li> should not be appended to.
          $element.after($clipNode);
        } else {
          $element.append($clipNode);
        }
      }

      if ($rootNode.height() > options.maxHeight) {
        if (child.nodeType === 3) { // text node
          truncated = truncateTextContent($child, $rootNode, $clipNode, options);
        } else {
          truncated = truncateNestedNode($child, $rootNode, $clipNode, options);
        }
      }

      if (!truncated && $clipNode.length) {
        $clipNode.remove();
      }

    }

    return truncated;
  }
1009952
public final void retag(final Element root, final String selector,
            final String tag) {
        final Iterable<Element> elements; // Elements selected

        checkNotNull(root, "Received a null pointer as root element");
        checkNotNull(selector, "Received a null pointer as selector");
        checkNotNull(tag, "Received a null pointer as tag");

        // Selects and iterates over the elements
        elements = root.select(selector);
        for (final Element element : elements) {
            element.tagName(tag);
        }
    }
708832
function(tag) {
		if (!tag) {
			// create a document fragment to hold multiple-root elements
			if (document.createDocumentFragment) {
				return document.createDocumentFragment();
			}

			tag = '';

		} else if (tag.charAt(0) === '!') {
			return document.createComment(tag === '!' ? '' : tag.substr(1)+' ');
		}

		return document.createElement(tag);
	}
925139
def nodeDumpOutput(self, doc, cur, level, format, encoding):
        
        if doc is None: doc__o = None
        else: doc__o = doc._o
        if cur is None: cur__o = None
        else: cur__o = cur._o
        libxml2mod.xmlNodeDumpOutput(self._o, doc__o, cur__o, level, format, encoding)
1109885
function sh_extractTagsFromNodeList(nodeList, result) {
  var length = nodeList.length;
  for (var i = 0; i < length; i++) {
    var node = nodeList.item(i);
    switch (node.nodeType) {
    case 1:
      if (node.nodeName.toLowerCase() === 'br') {
        var terminator;
        if (/MSIE/.test(navigator.userAgent)) {
          terminator = '\r';
        }
        else {
          terminator = '\n';
        }
        result.text.push(terminator);
        result.pos++;
      }
      else {
        result.tags.push({node: node.cloneNode(false), pos: result.pos});
        sh_extractTagsFromNodeList(node.childNodes, result);
        result.tags.push({pos: result.pos});
      }
      break;
    case 3:
    case 4:
      result.text.push(node.data);
      result.pos += node.length;
      break;
    }
  }
}
800015
function getNodes(tags, context) {
  var keys = objectKeys(tags);
  var returns = [];

  // keys to uppercase to compare to nodeName
  for(var i=0; i<keys.length; i++) keys[i]=keys[i].toUpperCase();

  // if context is tag
  if(keys.indexOf(context.nodeName.toUpperCase()) >= 0) {
    return [context];
  };

  //Mount all top-level child tags within context
  var nodes, el, mount, n;
  for(var i=0; i<keys.length; i++) {
    nodes = context.getElementsByTagName(keys[i]);
    for(n=0; n<nodes.length; n++) {
      el = nodes[n];
      mount = true;
      while(el = el.parentNode) {
        if(keys.indexOf(el.nodeName.toUpperCase()) >= 0) {
          mount = false;
          break;
        }
        if(el === context) break;
      }
      if(mount) returns.push(nodes[n]);
    }
  }  
  return returns;
}
875720
function () {
					oNodeForContext.nodeState.removed = false;
					var iNodeStateFound = that._aRemoved.indexOf(oNodeForContext);
					if (iNodeStateFound != -1) {
						that._aRemoved.splice(iNodeStateFound, 1);
					}
					// clear cache to make sure findNode etc. don't deliver wrong nodes (index is shifted due to adding)
					this._aNodeCache = [];
					that._cleanTreeStateMaps();
					that._fireChange({reason: ChangeReason.Add});
				}
218081
void writeTagNoClear(long bucketIndex, int posInBucket, long tag) {
		long tagStartIdx = getTagOffset(bucketIndex, posInBucket);
		// BIT BANGIN YEAAAARRHHHGGGHHH
		for (int i = 0; i < bitsPerTag; i++) {
			// second arg just does bit test in tag
			if ((tag & (1L << i)) != 0) {
				memBlock.set(tagStartIdx + i);
			}
		}
	}
371061
function (root, tagName) {
    var all = ReactTestUtils.scryRenderedDOMComponentsWithTag(root, tagName);
    if (all.length !== 1) {
      throw new Error('Did not find exactly one match (found: ' + all.length + ') ' + 'for tag:' + tagName);
    }
    return all[0];
  }