コード例 #1
0
ファイル: XmlUtils.java プロジェクト: burenin/dWebTek
 public static Document getXmlDocument(String fileName, boolean isWord) {
   File file = new File(fileName);
   SAXBuilder builder = new SAXBuilder();
   if (false) {
     builder.setValidation(true);
     builder.setProperty(
         "http://java.sun.com/xml/jaxp/properties/schemaSource",
         "http://localhost/Wiki/xsd/wikiXmlSchema.xsd");
   }
   try {
     return builder.build(file);
   } catch (Exception e) {
     return null;
   }
 }
コード例 #2
0
ファイル: XmlUtils.java プロジェクト: burenin/dWebTek
  public static Document getDocumentFromHttpGetRequest(String service, String xmlSchema)
      throws JDOMException {
    try {
      // Open connection to service
      HttpURLConnection connection = (HttpURLConnection) (new URL(service)).openConnection();

      connection.setRequestMethod("GET");
      connection.setConnectTimeout(150);
      connection.setReadTimeout(150);

      // Build document from inputstream
      InputStream in = connection.getInputStream();
      SAXBuilder builder = new SAXBuilder();
      if (false) {
        builder.setValidation(true);
        builder.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", xmlSchema);
      }
      return builder.build(in);
    } catch (IOException e) {
      return null;
    }
  }