returns the update xml buffer
764145
def prepare_update_xml(options = {})
      r = ["<add#{options.to_xml_attribute_string}>\n"]
      # copy and clear pending docs
      working_docs, @pending_documents = @pending_documents, nil
      working_docs.each { |doc| r << doc.xml }
      r << "\n</add>\n"
      r.join # not sure, but I think Array#join is faster then String#<< for large buffers
    end
1222152
def buffer_prev
      buffer_update_info
      if @_buffer_ctr < 1
        buffer_last
        return
      end
      @_buffer_ctr -= 1 if @_buffer_ctr > 0
      x = @_buffer_ctr
      l = @_buffers[x]
      if l
        populate_buffer_from_filename x
        l = @_buffers[x]
        $log.debug "bp calling set_content with #{l.class} "
        set_content l, @_buffers_conf[x]
        buffer_update_position
      end
    end
1357467
def gen_change_xml(change_list,comment=nil)
      #Get zone list and pick zone that matches most ending chars

      xml_str = ""
      xml = Builder::XmlMarkup.new(:target=>xml_str, :indent=>2)
      xml.instruct!
      xml.ChangeResourceRecordSetsRequest(:xmlns => @conn.endpoint+'doc/'+@conn.api+'/') { |req|
        req.ChangeBatch { |batch|
          batch.Comment(comment) unless comment.nil?
          batch.Changes { |changes|
            change_list.each { |change_item|
              change_item[:record].gen_change_xml(changes,change_item[:action])
            }
          }
        }
      }
      #puts "XML:\n#{xml_str}" if @conn.verbose
      return xml_str
    end
171066
def update(self):
        """"""
        response = self.jss.session.post(self.url, data=self.auth)
        response_xml = ElementTree.fromstring(response.text.encode("utf_8"))

        # Remove previous data, if any, and then add in response's XML.
        self.clear()
        for child in response_xml.getchildren():
            self.append(child)
327572
def get_xml(self, pdb_id):
        ''' '''
        self.tmp_string = None
        context = etree.iterparse(io.BytesIO(self.xml_contents), events=('end',), tag=self.PDBTM_entry_tag_type)
        try:
            fast_iter(context, self._get_xml, pdb_id = pdb_id.upper())
        except EarlyOut: pass
        return self.tmp_string
859049
public void updateByXml(Source source) throws IOException {
        checkPermission(CONFIGURE);
        StringWriter out = new StringWriter();
        try {
            // this allows us to use UTF-8 for storing data,
            // plus it checks any well-formedness issue in the submitted
            // data
            XMLUtils.safeTransform(source, new StreamResult(out));
            out.close();
        } catch (TransformerException|SAXException e) {
            throw new IOException("Failed to persist configuration.xml", e);
        }

        // try to reflect the changes by reloading
        try (InputStream in = new BufferedInputStream(new ByteArrayInputStream(out.toString().getBytes(StandardCharsets.UTF_8)))){
            // Do not allow overwriting view name as it might collide with another
            // view in same ViewGroup and might not satisfy Jenkins.checkGoodName.
            String oldname = name;
            ViewGroup oldOwner = owner; // oddly, this field is not transient
            Object o = Jenkins.XSTREAM2.unmarshal(XStream2.getDefaultDriver().createReader(in), this, null, true);
            if (!o.getClass().equals(getClass())) {
                // ensure that we've got the same view type. extending this code to support updating
                // to different view type requires destroying & creating a new view type
                throw new IOException("Expecting view type: "+this.getClass()+" but got: "+o.getClass()+" instead." +
                    "\nShould you needed to change to a new view type, you must first delete and then re-create " +
                    "the view with the new view type.");
            }
            name = oldname;
            owner = oldOwner;
        } catch (StreamException | ConversionException | Error e) {// mostly reflection errors
            throw new IOException("Unable to read",e);
        }
        save();
    }
421120
public void actionUpdateElements() throws JspException {

        try {
            List<CmsDialogElement> elementList = computeElements();
            CmsFile file = getCms().readFile(getParamTempfile(), CmsResourceFilter.IGNORE_EXPIRATION);
            CmsXmlPage page = CmsXmlPageFactory.unmarshal(getCms(), file);
            boolean foundMandatory = false;
            m_changeElement = "";
            Iterator<CmsDialogElement> i = elementList.iterator();
            while (i.hasNext()) {
                // get the current list element
                CmsDialogElement element = i.next();
                if (element.isMandantory()
                    || element.getName().equals(getParamElementname())
                    || Boolean.valueOf(
                        getJsp().getRequest().getParameter(PREFIX_PARAM_BODY + element.getName())).booleanValue()) {
                    if (!element.isExisting()) {
                        // create element in order to enable it properly
                        page.addValue(element.getName(), getElementLocale());
                    }
                    page.setEnabled(element.getName(), getElementLocale(), true);
                    if (element.isMandantory() && !foundMandatory) {
                        m_changeElement = element.getName();
                        foundMandatory = true;
                    }
                } else {
                    if (element.isExisting()) {
                        // remove element if it is already existing
                        page.removeValue(element.getName(), getElementLocale());
                    }
                }
            }
            // write the temporary file
            file.setContents(page.marshal());
            getCms().writeFile(file);
            // set the javascript functions which should be executed
            if (page.isEnabled(getParamElementname(), getElementLocale())) {
                m_changeElement = getParamElementname();
            } else if (!foundMandatory) {
                if (elementList.size() > 0) {
                    m_changeElement = elementList.get(0).getName();
                }
            }
        } catch (Throwable e) {
            // show error dialog
            setParamMessage(Messages.get().getBundle(getLocale()).key(Messages.ERR_UPDATE_ELEMENTS_0));
            includeErrorpage(this, e);
        }
    }
135395
def edit(request)
      render do |xml|
        xml.h2 "Update rack session"
        xml.p "Put marshalized and encoded with base64 ruby hash into the form"
        xml.form({
          :action  => action_path(:update),
          :method  => 'post',
          :enctype => 'application/x-www-form-urlencoded'
        }) do |form|
          form.input(:type => 'hidden', :name =>'_method', :value => 'put')
          form.textarea(:cols => 40, :rows => 10, :name => 'data') {}
          form.p do |p|
            p.input(:type => 'submit', :value => "Update")
          end
        end
      end
    end
464343
def update_DOM(self):
        
        response = self.fetch()
        self._DOM = html.fromstring(response.text)
        return self
1090974
def deserialize_reply(xml, update_time=False):
    
    if not xml:
        return EmptyReply()

    try:
        reply_dict = xmltodict.parse(xml)["xml"]
        msg_type = reply_dict["MsgType"]
    except (xmltodict.expat.ExpatError, KeyError):
        raise ValueError("bad reply xml")
    if msg_type not in REPLY_TYPES:
        raise ValueError("unknown reply type")

    cls = REPLY_TYPES[msg_type]
    kwargs = dict()
    for attr, field in cls._fields.items():
        if field.name in reply_dict:
            str_value = reply_dict[field.name]
            kwargs[attr] = field.from_xml(str_value)

    if update_time:
        kwargs["time"] = time.time()

    return cls(**kwargs)
68332
def update(self):
        
        diff = self._diff()
        if not diff:
            # Nothing to do!
            return
        self.parent.update_node(self, diff)
323535
def get(self, url, params=None):
        ''
        url = self.escapeUrl(url)

        content = six.BytesIO(self.raw(url, params=params))
        # We need to make sure that the xml fits in available memory before we parse
        # with lxml.objectify.fromstring(), or else it will bomb out.
        # If it is too big, we need to buffer it to disk before we run it through objectify. see #87
        #
        # get length of buffer
        content.seek(0,2)
        contentlen = content.tell()
        content.seek(0)

        MAX_BUFFER_SIZE=1024*1024*200 # 200MB. TODO: find a way to compute this
        if contentlen > MAX_BUFFER_SIZE:
            # xml is too big to parse with lxml.objectify.fromstring()
            contentfile = tempfile.NamedTemporaryFile()
            contentfile.write(content.read())
            o = lxml.objectify.parse(contentfile)
        else:
            o = lxml.objectify.fromstring(content.getvalue())
        if o.tag == 'error':
            JFSError.raiseError(o, url)
        return o
39593
def to_xml(self):
        """"""
        changesXML = ""
        for change in self.changes:
            changeParams = {"action": change[0], "record": change[1].to_xml()}
            changesXML += self.ChangeXML % changeParams
        params = {"comment": self.comment, "changes": changesXML}
        return self.ChangeResourceRecordSetsBody % params
70441
def _extract_updater(self):
        
        if self._node is self._buffer:
            return None
        else:
            updater = (self._node, self._buffer)
            self._buffer = self._node
            return updater
1196203
def relaxNGNewMemParserCtxt(buffer, size):
    
    ret = libxml2mod.xmlRelaxNGNewMemParserCtxt(buffer, size)
    if ret is None:raise parserError('xmlRelaxNGNewMemParserCtxt() failed')
    return relaxNgParserCtxt(_obj=ret)
376054
def update(self, use_template=False, **metadata_defaults):
        

        self.validate()

        tree_to_update = self._xml_tree if not use_template else self._get_template(**metadata_defaults)
        supported_props = self._metadata_props

        # Iterate over keys, and extract non-primitive root for all XPATHs
        #    xroot = identificationInfo/MD_DataIdentification/abstract/
        #    xpath = identificationInfo/MD_DataIdentification/abstract/CharacterString
        #
        # This prevents multiple primitive tags from being inserted under an element

        for prop, xpath in iteritems(self._data_map):
            if not prop.startswith('_') or prop.strip('_') in supported_props:
                # Send only public or alternate properties
                xroot = self._trim_xpath(xpath, prop)
                values = getattr(self, prop, u'')
                update_property(tree_to_update, xroot, xpath, prop, values, supported_props)

        return tree_to_update
972463
def retrieve_xml(pdb_id, silent = True):
    ''''''
    xml_gz = retrieve_file_from_RCSB(get_rcsb_files_connection(), "/download/%s.xml.gz" % pdb_id, silent = silent)
    cf = StringIO.StringIO()
    cf.write(xml_gz)
    cf.seek(0)
    df = gzip.GzipFile(fileobj = cf, mode='rb')
    contents = df.read()
    df.close()
    return contents