Codota Logo
DocumentException
Code IndexAdd Codota to your IDE (free)

How to use
DocumentException
in
org.dom4j

Best Java code snippets using org.dom4j.DocumentException (Showing top 20 results out of 909)

Refine searchRefine arrow

  • SAXReader
  • Document
  • Element
  • Document
  • Common ways to obtain DocumentException
private void myMethod () {
DocumentException d =
  • Codota IconThrowable cause;Throwable nestedException;new DocumentException(cause.getMessage(), nestedException)
  • Codota IconString message;new DocumentException(message)
  • Codota IconThrowable nestedException;new DocumentException("Could not load the DOM Document " + "class: " + name, nestedException)
  • Smart code suggestions by Codota
}
origin: Tencent/tinker

    final Document incXmlDoc = DocumentHelper.createDocument();
    final Element newRootNode = newXmlDoc.getRootElement();
    final String packageName = newRootNode.attributeValue(XML_NODEATTR_PACKAGE);
    if (Utils.isNullOrNil(packageName)) {
      throw new TinkerPatchException("Unable to find package name from manifest: " + newFile.getAbsolutePath());
    final Element newAppNode = newRootNode.element(XML_NODENAME_APPLICATION);
    final Element incAppNode = incXmlDoc.addElement(newAppNode.getQName());
    copyAttributes(newAppNode, incAppNode);
  throw new TinkerPatchException("Parse android manifest error!");
} catch (DocumentException e) {
  e.printStackTrace();
  throw new TinkerPatchException("Parse android manifest by dom4j error!");
} catch (IOException e) {
origin: igniterealtime/Openfire

public void configure(String pluginName) {
  try {
    SAXReader saxReader = new SAXReader();
    saxReader.setEncoding("UTF-8");
    Document cacheXml = saxReader.read(configDataStream);
    List<Node> mappings = cacheXml.selectNodes("/cache-config/cache-mapping");
    for (Node mapping: mappings) {
      registerCache(pluginName, mapping);
    }
  }
  catch (DocumentException e) {
    Log.error(e.getMessage(), e);
  }
}
origin: igniterealtime/Openfire

int loc = text.indexOf(" ");
if (loc >= 0) {
  document.addProcessingInstruction(text.substring(0, loc),
      text.substring(loc + 1));
  document.addProcessingInstruction(text, "");
  parent.addComment(pp.getText());
  document.addComment(pp.getText());
String text = pp.getText();
if (parent != null) {
  parent.addCDATA(text);
    throw new DocumentException("Cannot have text content outside of the root document");
String text = pp.getText();
if (parent != null) {
  parent.addText(text);
    throw new DocumentException("Cannot have an entityref outside of the root document");
    throw new DocumentException("Cannot have text content outside of the root document");
origin: spotbugs/spotbugs

DocumentException e2 = new DocumentException("Error parsing " + newFilename);
e2.initCause(e);
if (verbose) {
  e2.printStackTrace();
origin: com.gitee.rslai.base.tool/servertest

private Element loadXml(String fileName) {
  Element element = (Element) INCLUDED.get(fileName);
  if (element != null) return element;
  String content = read(fileName);
  SAXReader reader = new SAXReader();
  StringReader stream = new StringReader(content);
  try {
    Element root = reader.read(stream).getRootElement();
    INCLUDED.put(fileName, root);
    return root;
  } catch (DocumentException e) {
    logger.error("读取include指令指定的文件失败", e);
    throw new RuntimeException(e.getMessage(), e);
  }
}
origin: com.github.becausetesting/commons

public DOM4JUtils(InputStream inputStream) {
  try {
    // document = reader.read(new
    // ByteArrayInputStream(xml.getBytes("UTF-8")));
    document = new SAXReader().read(inputStream);
  } catch (DocumentException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
  }
}
origin: WeDevelopTeam/HeroVideo-master

  private String parseLiveUrl(ResponseBody responseBody) {
    String xml = null;
    try {
      xml = responseBody.string();
    } catch (IOException e) {
      e.printStackTrace();
    }
    LogUtil.d("xml", xml);
    Document document = null;
    try {
      document = DocumentHelper.parseText(xml);
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    assert document != null;
    Element rootElement = document.getRootElement();
    Element durlElement = rootElement.element("durl");
    Element urlElement = durlElement.element("url");
    String url = urlElement.getText();
    return url;
  }
}
origin: bioinformatics-ua/dicoogle

public String getType()
{
  SAXReader saxReader = new SAXReader();
  ByteArrayInputStream input = new ByteArrayInputStream(Message.getBytes());
  Document document = null;
  try
  {
    document = saxReader.read(input);
  } catch (DocumentException ex)
  {
    ex.printStackTrace(System.out);
  }
  Element root = document.getRootElement();
  Element tmp = root.element(MessageFields.MESSAGE_TYPE);
  return tmp.getText();
}
origin: org.dom4j/dom4j

/**
 * Parses the specified {@link java.io.File}, using the given {@link
 * java.nio.charset.Charset}.
 * 
 * @param file
 *            the file to parse
 * @param charset
 *            the charset to be used
 * 
 * @return the resulting DOM4J document
 * 
 * @throws DocumentException
 *             when an error occurs while parsing
 */
public Document read(File file, Charset charset) throws DocumentException {
  try {
    Reader xmlReader = new InputStreamReader(new FileInputStream(file),
        charset);
    return getReader().read(xmlReader);
  } catch (JAXBRuntimeException ex) {
    Throwable cause = ex.getCause();
    throw new DocumentException(cause.getMessage(), cause);
  } catch (FileNotFoundException ex) {
    throw new DocumentException(ex.getMessage(), ex);
  }
}
origin: ucarGroup/DataLink

@POST
@Path("/toEditLogback/{workerId}")
public Map<String, String> toEditLogback(@PathParam("workerId") String workerId) throws Throwable {
  logger.info("Receive a request to edit logback.xml, with workerId " + workerId);
  String path = System.getProperty("logback.configurationFile");
  SAXReader reader = new SAXReader();
  Map<String, String> result = new HashMap<>();
  try {
    Document document = reader.read(new File(path));
    result.put("content", document.asXML());
    return result;
  } catch (DocumentException e) {
    logger.info("reading logback.xml error:", e);
    result.put("content", e.getMessage());
  }
  return result;
}
origin: dermotte/liresolr

  @Override
  public void run() {
    SAXReader reader = new SAXReader();
    try {
      Document document = reader.read(new FileInputStream(infile));
      Element root = document.getRootElement();
      for (Iterator<Element> it = root.elementIterator(); it.hasNext(); ) {
        Element doc = it.next();
        String file_path = doc.selectSingleNode("field[@name='localimagefile']").getText();
        outStream.println(file_path);
      }
    } catch (DocumentException e) {
      e.printStackTrace();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
    outStream.close();
  }
}
origin: stackoverflow.com

 protected List<String> getSecurityRoles() {
  List<String> roles = new ArrayList<String>();
  ServletContext sc = this.getServletContext();
  InputStream is = sc.getResourceAsStream("/WEB-INF/web.xml");

  try {
    SAXReader reader = new SAXReader();
    Document doc = reader.read(is);

    Element webApp = doc.getRootElement();

    // Type safety warning:  dom4j doesn't use generics
    List<Element> roleElements = webApp.elements("security-role");
    for (Element roleEl : roleElements) {
      roles.add(roleEl.element("role-name").getText());
    }
  } catch (DocumentException e) {
    e.printStackTrace();
  }

  return roles;
}
origin: com.atlassian.jira.plugins/jira-fisheye-plugin

  result = xmlReader.read(responseReader);
if ("error".equals(result.getRootElement().getName()))
  throw new ResponseException(result.getRootElement().getText());
throw new ResponseException(String.format("Failed to parse FishEye response: %s", XMLUtils.escape(e.getMessage())), e);
origin: org.jboss.seam/jboss-seam

public static Element getRootElement(InputStream stream) throws DocumentException
{
  try {
    SAXReader saxReader = new SAXReader();
    saxReader.setEntityResolver(new DTDEntityResolver());
    saxReader.setMergeAdjacentText(true);
    return saxReader.read(stream).getRootElement();
  } catch (DocumentException e) {
    Throwable nested = e.getNestedException();
    if (nested!= null) {
      if (nested instanceof FileNotFoundException) {
        throw new RuntimeException("Can't find schema/DTD reference: " +
            nested.getMessage(), e);
      } else if (nested instanceof UnknownHostException) {
        throw new RuntimeException("Cannot connect to host from schema/DTD reference: " + 
            nested.getMessage() + 
            " - check that your schema/DTD reference is current", e);
      }
    }
    throw e;
  }
}
origin: stackoverflow.com

 public static void main(String[] args) throws SAXException {
  String xml = "<root><item><errorCode>1</errorCode><errorDescription></errorDescription></item>"+"<item><errorCode>2</errorCode><errorDescription></errorDescription></item></root>";
  SAXReader reader = new SAXReader();
  Document doc = null;
  try {
    doc = reader.read(new ByteArrayInputStream(xml.getBytes()));
    @SuppressWarnings("unchecked")
    List<Element> list = doc.selectNodes("/root/item");
    for(Element el : list){
      Element errorCode = (Element) el.selectNodes("errorCode").get(0);
      Element errorDescription = (Element) el.selectNodes("errorDescription").get(0);
      System.out.println(errorCode.getText() + " : " + errorDescription.getText());
    }
  }catch (DocumentException e) {
    e.printStackTrace();
  }
}
origin: org.nuxeo.ecm.platform/nuxeo-platform-audit-io

private static Document loadXML(InputStream in) throws IOException {
  try {
    // the SAXReader is closing the stream so that we need to copy the
    // content somewhere
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    IOUtils.copy(in, baos);
    return new SAXReader().read(new ByteArrayInputStream(baos.toByteArray()));
  } catch (DocumentException e) {
    IOException ioe = new IOException("Failed to read log entry " + ": " + e.getMessage());
    ioe.setStackTrace(e.getStackTrace());
    throw ioe;
  }
}
origin: org.ow2.jasmine/mbeancmd-core

SAXReader reader = new SAXReader();
reader.setValidation(true);
reader.setStripWhitespaceText(false);
reader.setEntityResolver(new MyEntityResolver());
  doc = reader.read(configuration);
} catch (DocumentException e) {
  if (e.getNestedException() instanceof java.io.FileNotFoundException) {
    System.out.println("FileNotFoundException for configuration file: " + configuration);
    throw (java.io.FileNotFoundException) e.getNestedException();
  e.printStackTrace();
origin: com.github.fosin/cdp-utils

/** {@inheritDoc} */
@Override
public Element convert(String source) {
  try {
    return DocumentHelper.parseText(source).getRootElement();
  } 
  catch (DocumentException e) {
    throw new IllegalArgumentException("Failed to parse xml " + source + ", cause: " + e.getMessage(), e);
  }
}
origin: huangfangyi/YiChat

  @Override
  public void onResponse(Call call, Response response) throws IOException {
    Document doc = null;
    try {
      doc = DocumentHelper.parseText(response.body().string());
    } catch (DocumentException e) {
      e.printStackTrace();
    }
    Element root = doc.getRootElement();
    String recCode = root.elementText("code");
    String recMsg = root.elementText("msg");
    listener.onSuccess(recCode, recMsg, String.valueOf(smsCode));
    Log.d(TAG,"-----验证码:"+smsCode);
  }
});
origin: stackoverflow.com

Element elRoot = documentOld.getRootElement();
Element elRootCopy = (Element) elRoot.clone();
documentNew.add(elRootCopy);
saxReader = new SAXReader();
document = saxReader.read(new File(pathname));
e.printStackTrace();
org.dom4jDocumentException

Javadoc

DocumentException is a nested Exception which may be thrown during the processing of a DOM4J document.

Most used methods

  • printStackTrace
  • getMessage
  • <init>
  • getNestedException
  • getStackTrace
  • initCause
  • getCause
  • toString

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (ScheduledExecutorService)
  • findViewById (Activity)
  • getContentResolver (Context)
  • FileInputStream (java.io)
    A FileInputStream obtains input bytes from a file in a file system. What files are available depends
  • LinkedHashMap (java.util)
    Hash table and linked list implementation of the Map interface, with predictable iteration order. Th
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Vector (java.util)
    The Vector class implements a growable array of objects. Like an array, it contains components that
  • Handler (java.util.logging)
    A Handler object accepts a logging request and exports the desired messages to a target, for example
  • JOptionPane (javax.swing)
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now