Project

General

Profile

« Previous | Next » 

Revision 1903

Added by Jing Tao about 21 years ago

Get rid of doctype declare in transfer.

View differences:

src/edu/ucsb/nceas/metacat/DBTransform.java
156 156
          }
157 157
        }
158 158
        
159
       
159
        doc = removeDOCTYPE(doc);
160 160
        StreamSource xml = new StreamSource(new StringReader(doc));
161 161
        //modify the system id for dtd
162
        modifiedXmlStreamSource(xml, sourceType);
162
        //modifiedXmlStreamSource(xml, sourceType);
163 163
        transformer.transform(xml, new StreamResult(pw));
164 164
      } catch (Exception e) {
165 165
        pw.println(xslSystemId + "Error transforming document in " +
......
201 201
          transformer.setParameter("sessid", sessionid);
202 202
        }
203 203
        transformer.setParameter("qFormat", qFormat);
204
        doc = removeDOCTYPE(doc);
204 205
        StreamSource xml = new StreamSource(new StringReader(doc));
205 206
        //modify the system id for dtd
206
        modifiedXmlStreamSource(xml, sourceType);
207
        //modifiedXmlStreamSource(xml, sourceType);
207 208
        transformer.transform(xml, new StreamResult(pw));
208 209
      } catch (Exception e) {
209 210
        util.debugMessage(xslSystemId + "Error transforming document in " +
......
386 387
    //set system id to input stream
387 388
    xml.setSystemId(systemId);
388 389
  }
390
  
391
  /*
392
   * removes the DOCTYPE element and its contents from a Sting
393
   * used to avoid problems with incorrect SystemIDs 
394
   */
395
  private String removeDOCTYPE(String in) {  
396
    String ret = "";
397
    int startpos = in.indexOf("<!DOCTYPE");
398
    if (startpos>-1) {
399
      int stoppos = in.indexOf(">", startpos + 8);   
400
      ret = in.substring(0,startpos) + in.substring(stoppos+1,in.length());
401
    } else {
402
      return in;
403
    }
404
    return ret;  
405
  }
389 406

  
390 407
  /**
391 408
   * the main routine used to test the transform utility.

Also available in: Unified diff