docs: function(request) {       
          if (!request) {
              request = this.request;
          }    
          var root = this.createElementNS("", "ARCXML");
          root.setAttribute("version","1.1");
  
          var reqElem = this.createElementNS("", "REQUEST");
          
          if (request.get_image != null) {
              var getElem = this.createElementNS("", "GET_IMAGE");
              reqElem.appendChild(getElem);
  
              var propElem = this.createElementNS("", "PROPERTIES");
              getElem.appendChild(propElem);
  
              var props = request.get_image.properties;
              if (props.featurecoordsys != null) {
                  var feat = this.createElementNS("", "FEATURECOORDSYS");
                  propElem.appendChild(feat);
                  
                  if (props.featurecoordsys.id === 0) {
                      feat.setAttribute("string", props.featurecoordsys['string']);
                  }
                  else {
                      feat.setAttribute("id", props.featurecoordsys.id);
                  }
              }
            
              if (props.filtercoordsys != null) {
                  var filt = this.createElementNS("", "FILTERCOORDSYS");
                  propElem.appendChild(filt);
  
                  if (props.filtercoordsys.id === 0) {
                      filt.setAttribute("string", props.filtercoordsys.string);
                  }
                  else {
                      filt.setAttribute("id", props.filtercoordsys.id);
                  }
              }
            
              if (props.envelope != null) {
                  var env = this.createElementNS("", "ENVELOPE");
                  propElem.appendChild(env);
  
                  env.setAttribute("minx", props.envelope.minx);
                  env.setAttribute("miny", props.envelope.miny);
                  env.setAttribute("maxx", props.envelope.maxx);
                  env.setAttribute("maxy", props.envelope.maxy);
              }        
            
              var imagesz = this.createElementNS("", "IMAGESIZE");
              propElem.appendChild(imagesz);
            
              imagesz.setAttribute("height", props.imagesize.height);
              imagesz.setAttribute("width", props.imagesize.width);
            
              if (props.imagesize.height != props.imagesize.printheight ||
                   props.imagesize.width != props.imagesize.printwidth) {
                  imagesz.setAttribute("printheight", props.imagesize.printheight);
                  imagesz.setArrtibute("printwidth", props.imagesize.printwidth);
              }
            
              if (props.background != null) {
                  var backgrnd = this.createElementNS("", "BACKGROUND");
                  propElem.appendChild(backgrnd);
              
                  backgrnd.setAttribute("color", 
                      props.background.color.r + "," + 
                      props.background.color.g + "," + 
                      props.background.color.b);
                
                  if (props.background.transcolor !== null) {
                      backgrnd.setAttribute("transcolor", 
                          props.background.transcolor.r + "," + 
                          props.background.transcolor.g + "," + 
                          props.background.transcolor.b);
                  }
              }
            
              if (props.layerlist != null && props.layerlist.length > 0) {
                  var layerlst = this.createElementNS("", "LAYERLIST");
                  propElem.appendChild(layerlst);
              
                  for (var ld = 0; ld < props.layerlist.length; ld++) {
                      var ldef = this.createElementNS("", "LAYERDEF");
                      layerlst.appendChild(ldef);
                
                      ldef.setAttribute("id", props.layerlist[ld].id);
                      ldef.setAttribute("visible", props.layerlist[ld].visible);
                
                      if (typeof props.layerlist[ld].query == "object") {
                          var query = props.layerlist[ld].query;
  
                          if (query.where.length < 0) {
                              continue;
                          }
                    
                          var queryElem = null;
                          if (typeof query.spatialfilter == "boolean" && query.spatialfilter) {
                              // handle spatial filter madness
                              queryElem = this.createElementNS("", "SPATIALQUERY");
                          }
                          else {
                              queryElem = this.createElementNS("", "QUERY");
                          }
                  
                          queryElem.setAttribute("where", query.where);
                  
                          if (typeof query.accuracy == "number" && query.accuracy > 0) {
                              queryElem.setAttribute("accuracy", query.accuracy);
                          }
                          if (typeof query.featurelimit == "number" && query.featurelimit < 2000) {
                              queryElem.setAttribute("featurelimit", query.featurelimit);
                          }
                          if (typeof query.subfields == "string" && query.subfields != "#ALL#") {
                              queryElem.setAttribute("subfields", query.subfields);
                          }
                          if (typeof query.joinexpression == "string" && query.joinexpression.length > 0) {
                              queryElem.setAttribute("joinexpression", query.joinexpression);
                          }
                          if (typeof query.jointables == "string" && query.jointables.length > 0) {
                              queryElem.setAttribute("jointables", query.jointables);
                          }
  
                          ldef.appendChild(queryElem);
                      }
                
                      if (typeof props.layerlist[ld].renderer == "object") {
                          this.addRenderer(ldef, props.layerlist[ld].renderer);                  
                      }
                  }
              }
          } else if (request.get_feature != null) {
              var getElem = this.createElementNS("", "GET_FEATURES");
              getElem.setAttribute("outputmode", "newxml");
              getElem.setAttribute("checkesc", "true");
            
              if (request.get_feature.geometry) {
                  getElem.setAttribute("geometry", request.get_feature.geometry);
              }
              else {
                  getElem.setAttribute("geometry", "false");
              }
            
              if (request.get_feature.compact) {
                  getElem.setAttribute("compact", request.get_feature.compact);
              }
            
              if (request.get_feature.featurelimit == "number") {
                  getElem.setAttribute("featurelimit", request.get_feature.featurelimit);
              }
            
              getElem.setAttribute("globalenvelope", "true");
              reqElem.appendChild(getElem);
            
              if (request.get_feature.layer != null && request.get_feature.layer.length > 0) {
                  var lyrElem = this.createElementNS("", "LAYER");
                  lyrElem.setAttribute("id", request.get_feature.layer);
                  getElem.appendChild(lyrElem);
              }
            
              var fquery = request.get_feature.query;
              if (fquery != null) {
                  var qElem = null;
                  if (fquery.isspatial) {
                      qElem = this.createElementNS("", "SPATIALQUERY");
                  } else {
                      qElem = this.createElementNS("", "QUERY");
                  }
                  getElem.appendChild(qElem);
                  
                  if (typeof fquery.accuracy == "number") {
                      qElem.setAttribute("accuracy", fquery.accuracy);
                  }
                  //qElem.setAttribute("featurelimit", "5");
              
                  if (fquery.featurecoordsys != null) {
                      var fcsElem1 = this.createElementNS("", "FEATURECOORDSYS");
                
                      if (fquery.featurecoordsys.id == 0) {
                          fcsElem1.setAttribute("string", fquery.featurecoordsys.string);
                      } else {
                          fcsElem1.setAttribute("id", fquery.featurecoordsys.id);
                      }
                      qElem.appendChild(fcsElem1);
                  }
              
                  if (fquery.filtercoordsys != null) {
                      var fcsElem2 = this.createElementNS("", "FILTERCOORDSYS");
                
                      if (fquery.filtercoordsys.id === 0) {
                          fcsElem2.setAttribute("string", fquery.filtercoordsys.string);
                      } else {
                          fcsElem2.setAttribute("id", fquery.filtercoordsys.id);
                      }
                      qElem.appendChild(fcsElem2);
                  }
              
                  if (fquery.buffer > 0) {   
                      var bufElem = this.createElementNS("", "BUFFER");
                      bufElem.setAttribute("distance", fquery.buffer);
                      qElem.appendChild(bufElem);
                  }
              
                  if (fquery.isspatial) {
                      var spfElem = this.createElementNS("", "SPATIALFILTER");
                      spfElem.setAttribute("relation", fquery.spatialfilter.relation);
                      qElem.appendChild(spfElem);
                
                      if (fquery.spatialfilter.envelope) {
                          var envElem = this.createElementNS("", "ENVELOPE"); 
                          envElem.setAttribute("minx", fquery.spatialfilter.envelope.minx);
                          envElem.setAttribute("miny", fquery.spatialfilter.envelope.miny);
                          envElem.setAttribute("maxx", fquery.spatialfilter.envelope.maxx);
                          envElem.setAttribute("maxy", fquery.spatialfilter.envelope.maxy);
                          spfElem.appendChild(envElem);
                      } else if(typeof fquery.spatialfilter.polygon == "object") {
                          spfElem.appendChild(this.writePolygonGeometry(fquery.spatialfilter.polygon));                
                      }
                  }
              
                  if (fquery.where != null && fquery.where.length > 0) {
                      qElem.setAttribute("where", fquery.where);
                  }
              }
          }
  
          root.appendChild(reqElem);
  
          return OpenLayers.Format.XML.prototype.write.apply(this, [root]);
      }