int num_records = 0;
String res_id = "";
long idle = 0;
if ( ( result.records != null ) && ( result.records.length > 0 ) ) {
DOMBuilder builder = new DOMBuilder();
num_records = result.records.length;
res_id = result.result_set_id;
idle = result.result_set_idle_time ;
for ( int i=0; i<result.records.length;i++ ) {
Element elem = new Element("record");
elem.setAttribute( new Attribute("recordPosition",""+first_record+i));
ExplicitRecordFormatSpecification res = result.records[i].getFormatSpecification();
// check if the format corresponds to what we are requesting
if ( ! res.toString().equals(display_spec.toString()) ) {
Log.error(Geonet.SRU, "error, format specification "+result.records[i].getFormatSpecification()+" does not correspond to "+display_spec+" :"+result.records[i].getOriginalObject() );
addToDiag(elem, "info:srw/diagnostic/1/67", "Record not available in this schema", result.records[i].getOriginalObject().toString());
//throw new Exception("SRU error:"+result.records[i].getOriginalObject());
}
else if (result.records[i].getOriginalObject() instanceof org.jdom.Document )
{
org.jdom.Document doc = (org.jdom.Document)result.records[i].getOriginalObject();
Element e = doc.getRootElement();
e.detach();
elem.addContent(e);
}
else if (result.records[i].getOriginalObject() instanceof Document )
{
Document d = (Document)result.records[i].getOriginalObject();
// FIXME: ARHHHHH!!!!! this is inefficient... there must be another way of doing this
org.jdom.Document doc = builder.build(d);
Element e = doc.getRootElement();
e.detach();
elem.addContent( e ) ;