Set the root element of the document (doc->children is a
           list containing possibly comments, PIs, etc ...).
976023
def docSetRootElement(self, doc):
        
        if doc is None: doc__o = None
        else: doc__o = doc._o
        ret = libxml2mod.xmlDocSetRootElement(doc__o, self._o)
        if ret is None:return None
        __tmp = xmlNode(_obj=ret)
        return __tmp
935951
static Element appendChild(Element plfChild, Element parent, boolean copyChildren) {
        Document document = parent.getOwnerDocument();
        Element copy = (Element) document.importNode(plfChild, false);
        parent.appendChild(copy);

        // set the identifier for the doc if warrented
        String id = copy.getAttribute(Constants.ATT_ID);
        if (id != null && !id.equals("")) copy.setIdAttribute(Constants.ATT_ID, true);

        if (copyChildren) {
            NodeList children = plfChild.getChildNodes();
            for (int i = 0; i < children.getLength(); i++) {
                if (children.item(i) instanceof Element)
                    appendChild((Element) children.item(i), copy, true);
            }
        }
        return copy;
    }
1091887
def set_attributes(self, doc, fields, parent_type=None):
        

        if parent_type:
            assert isinstance(parent_type, Struct)

        self.subtypes = []

        # These are only set if this struct enumerates subtypes.
        self._enumerated_subtypes = None  # Optional[List[Tuple[str, DataType]]]
        self._is_catch_all = None  # Optional[Bool]

        super(Struct, self).set_attributes(doc, fields, parent_type)

        if self.parent_type:
            self.parent_type.subtypes.append(self)
159351
public function set_parent(Node_Container $parent=null)
	{
		$this->parent = $parent;

		if($parent instanceof Node_Container_Document)
			$this->root = $parent;
		else
			$this->root = $parent->root();
	}
462471
public function setRootAndPath(Document $root, $path)
    {
        $this->getArchive()->set('root_and_path', array('root' => $root, 'path' => $path));

        foreach ($this->getAdd() as $key => $document) {
            $document->setRootAndPath($root, $path.'._add'.$key);
        }
    }
582640
def add_child(self, child):
        ''''''
        super(RootNode, self).add_child(child)
        child.attr_wrapper = self.attr_wrapper
293505
public void setRtfDocument(RtfDocument doc) {
        this.document = doc;
        if(headerAll != null) {
            headerAll.setRtfDocument(this.document);
        }
        if(headerFirst != null) {
            headerFirst.setRtfDocument(this.document);
        }
        if(headerLeft != null) {
            headerLeft.setRtfDocument(this.document);
        }
        if(headerRight != null) {
            headerRight.setRtfDocument(this.document);
        }
    }
376304
def doc_children(self, doctype, limiters=[]):
        
        result = []
        for doc in self.docstring:
            if len(limiters) == 0 or doc.doctype in limiters:
                result.extend(doc.children(doctype))

        return result
975973
private void addRulesFromDocument(Document document) {
        NodeList ruleNodes = document.getElementsByTagName("rule");
        for (int i = 0; i < ruleNodes.getLength(); i++) {
            addRule(extractClassAttributeFromNode(ruleNodes.item(i)), extractPriorityAttributeFromNode(ruleNodes.item(i)));
        }
    }
265582
def apply(self, doc, clear, **kwargs):
        

        # Reattach doc with the current session or DetachedInstanceError happens
        doc = self.session.merge(doc)
        # Iterate over each mention class
        for i, mention_class in enumerate(self.mention_classes):
            tc_to_insert = defaultdict(list)
            # Generate TemporaryContexts that are children of the context using
            # the mention_space and filtered by the Matcher
            self.child_context_set.clear()
            for tc in self.matchers[i].apply(self.mention_spaces[i].apply(doc)):
                rec = tc._load_id_or_insert(self.session)
                if rec:
                    tc_to_insert[tc._get_table()].append(rec)
                self.child_context_set.add(tc)

            # Bulk insert temporary contexts
            for table, records in tc_to_insert.items():
                stmt = insert(table.__table__).values(records)
                self.session.execute(stmt)

            # Generates and persists mentions
            mention_args = {"document_id": doc.id}
            for child_context in self.child_context_set:
                # Assemble mention arguments
                for arg_name in mention_class.__argnames__:
                    mention_args[arg_name + "_id"] = child_context.id

                # Checking for existence
                if not clear:
                    q = select([mention_class.id])
                    for key, value in list(mention_args.items()):
                        q = q.where(getattr(mention_class, key) == value)
                    mention_id = self.session.execute(q).first()
                    if mention_id is not None:
                        continue

                # Add Mention to session
                yield mention_class(**mention_args)
10968
void setCurrent(TreePath path, DocCommentTree comment) {
        currPath = path;
        currDocComment = comment;
        currElement = trees.getElement(currPath);
        currOverriddenMethods = ((JavacTypes) types).getOverriddenMethods(currElement);

        AccessKind ak = AccessKind.PUBLIC;
        for (TreePath p = path; p != null; p = p.getParentPath()) {
            Element e = trees.getElement(p);
            if (e != null && e.getKind() != ElementKind.PACKAGE) {
                ak = min(ak, AccessKind.of(e.getModifiers()));
            }
        }
        currAccess = ak;
    }
372917
def add( child )
      if child.kind_of? ( XMLDecl )
        if @children[0].kind_of?( XMLDecl )
          @children[0] = child
        else
          @children.unshift child
        end
        child.parent = self
      elsif child.kind_of? DocType
        # Find first Element or DocType node and insert the decl right 
        # before it.  If there is no such node, just insert the child at the
        # end.  If there is a child and it is an DocType, then replace it.
        insert_before_index = @children.find_index { |x|
          x.kind_of?(Element) || x.kind_of?(DocType)
        }
        if insert_before_index # Not null = not end of list
          if @children[ insert_before_index ].kind_of? DocType
            @children[ insert_before_index ] = child
          else
            @children[ insert_before_index-1, 0 ] = child
          end
        else  # Insert at end of list
          @children << child
        end
        child.parent = self
      else
        rv = super
        raise "attempted adding second root element to document" if @elements.size > 1
        rv
      end
    end
455651
private static function _setDocId(&$subdoc, &$parentNode, $id, &$docIdXpath, $curLevel = 0) {
        if ($parentNode->nodeName == $docIdXpath[$curLevel]) {
            if ($curLevel == count($docIdXpath) - 1) {
                // remove all sub-nodes
                $curChild = $parentNode->firstChild;
                while ($curChild) {
                    $nextChild = $curChild->nextSibling;
                    $parentNode->removeChild($curChild);
                    $curChild = $nextChild;
                }
                // set the ID
                if (!CPS_Request::isValidUTF8((string) $id))
                	throw new CPS_Exception(array(array('long_message' => 'Invalid UTF-8 encoding in document ID', 'code' => ERROR_CODE_INVALID_UTF8, 'level' => 'ERROR', 'source' => 'CPS_API')));
                $textNode = $subdoc->createTextNode($id);
                $parentNode->appendChild($textNode);
            } else {
                // traverse children
                $found = false;
                $curChild = $parentNode->firstChild;
                while ($curChild) {
                    if ($curChild->nodeName == $docIdXpath[$curLevel + 1]) {
                        CPS_Request::_setDocId($subdoc, $curChild, $id, $docIdXpath, $curLevel + 1);
                        $found = true;
                        break;
                    }
                    $curChild = $curChild->nextSibling;
                }
                if (!$found) {
                    $newNode = $subdoc->createElement($docIdXpath[$curLevel + 1]);
                    $parentNode->appendChild($newNode);
                    CPS_Request::_setDocId($subdoc, $newNode, $id, $docIdXpath, $curLevel + 1);
                }
            }
        } else {
            throw new CPS_Exception(array(array('long_message' => 'Document root xpath not matching document ID xpath', 'code' => ERROR_CODE_INVALID_XPATHS, 'level' => 'REJECTED', 'source' => 'CPS_API')));
        }
    }
510867
protected function initRootElement()
    {
        if ($this->domDocument->hasChildNodes()) {
            foreach ($this->domDocument->childNodes as $node) {
                if ($node instanceof \DOMElement) {
                    $this->rootElement = $this->getElementHandler($node, $this);
                    break;
                }
            }
        } else {
            throw new \InvalidArgumentException('Document seems to be invalid', __LINE__);
        }
    }
709286
function findRootNode(document)
{
	var i;
	var rootNodes = document.childNodes;
	
	for (i=0; i<rootNodes.length; i++)
	{
		// Doctypes have no `childNodes` property
		if (rootNodes[i].childNodes != null)
		{
			return rootNodes[i];
		}
	}
}
1052361
def set_parent(self, parent):
        '''
        '''
        if not isinstance(parent, Node):
            raise TypeError("parent must be a Node")
        self.parent = parent
842942
def set_project_nodes(self, root_node, maximum_depth=1):
        

        root_directory = root_node.path
        for parent_directory, directories, files in foundations.walkers.depth_walker(root_directory, maximum_depth):
            if parent_directory == root_directory:
                parent_node = root_node
            else:
                parent_node = foundations.common.get_first_item(
                    [node for node in foundations.walkers.nodes_walker(root_node)
                     if node.family == "Directory" and node.path == parent_directory])

            if not parent_node:
                continue

            paths = [node.path for node in parent_node.children]
            for directory in sorted(directories):
                if directory.startswith("."):
                    continue

                path = os.path.join(parent_directory, directory)
                if path in paths:
                    continue

                directory_node = self.register_directory(path, parent_node)

            for file in sorted(files):
                if file.startswith("."):
                    continue

                path = os.path.join(parent_directory, file)
                if path in paths:
                    continue

                if foundations.io.is_readable(path):
                    if foundations.io.is_binary_file(path):
                        continue

                file_node = self.register_file(path, parent_node)