code:   public SolrInputDocument readDoc(XMLStreamReader parser) throws XMLStreamException {
      SolrInputDocument doc = new SolrInputDocument();
  
      String attrName = "";
      for (int i = 0; i < parser.getAttributeCount(); i++) {
        attrName = parser.getAttributeLocalName(i);
        if ("boost".equals(attrName)) {
          doc.setDocumentBoost(Float.parseFloat(parser.getAttributeValue(i)));
        } else {
          log.warn("Unknown attribute doc/@" + attrName);
        }
      }
  
      StringBuilder text = new StringBuilder();
      String name = null;
      float boost = 1.0f;
      boolean isNull = false;
      String update = null;
  
      while (true) {
        int event = parser.next();
        switch (event) {
          // Add everything to the text
          case XMLStreamConstants.SPACE:
          case XMLStreamConstants.CDATA:
          case XMLStreamConstants.CHARACTERS:
            text.append(parser.getText());
            break;
  
          case XMLStreamConstants.END_ELEMENT:
            if ("doc".equals(parser.getLocalName())) {
              return doc;
            } else if ("field".equals(parser.getLocalName())) {
              Object v = isNull ? null : text.toString();
              if (update != null) {
                Map<String,Object> extendedValue = new HashMap<String,Object>(1);
                extendedValue.put(update, v);
                v = extendedValue;
              }
              doc.addField(name, v, boost);
              boost = 1.0f;
            }
            break;
  
          case XMLStreamConstants.START_ELEMENT:
            text.setLength(0);
            String localName = parser.getLocalName();
            if (!"field".equals(localName)) {
              log.warn("unexpected XML tag doc/" + localName);
              throw new SolrException(SolrException.ErrorCode.BAD_REQUEST,
                      "unexpected XML tag doc/" + localName);
            }
            boost = 1.0f;
            update = null;
            String attrVal = "";
            for (int i = 0; i < parser.getAttributeCount(); i++) {
              attrName = parser.getAttributeLocalName(i);
              attrVal = parser.getAttributeValue(i);
              if ("name".equals(attrName)) {
                name = attrVal;
              } else if ("boost".equals(attrName)) {
                boost = Float.parseFloat(attrVal);
              } else if ("null".equals(attrName)) {
                isNull = StrUtils.parseBoolean(attrVal);
              } else if ("update".equals(attrName)) {
                update = attrVal;
              } else {
                log.warn("Unknown attribute doc/field/@" + attrName);
              }
            }
            break;
        }
      }
    }
  