Package org.dom4j

Examples of org.dom4j.DocumentException


                    if (parent != null) {
                        parent.addCDATA(pp.getText());
                    } else {
                        String msg = "Cannot have text content outside of the "
                                + "root document";
                        throw new DocumentException(msg);
                    }

                    break;
                }

                case XmlPullParser.ENTITY_REF:
                    break;

                case XmlPullParser.END_DOCUMENT:
                    return document;

                case XmlPullParser.START_TAG: {
                    QName qname = (pp.getPrefix() == null) ? df.createQName(pp
                            .getName(), pp.getNamespace()) : df.createQName(pp
                            .getName(), pp.getPrefix(), pp.getNamespace());
                    Element newElement = df.createElement(qname);
                    int nsStart = pp.getNamespaceCount(pp.getDepth() - 1);
                    int nsEnd = pp.getNamespaceCount(pp.getDepth());

                    for (int i = nsStart; i < nsEnd; i++) {
                        if (pp.getNamespacePrefix(i) != null) {
                            newElement.addNamespace(pp.getNamespacePrefix(i),
                                    pp.getNamespaceUri(i));
                        }
                    }

                    for (int i = 0; i < pp.getAttributeCount(); i++) {
                        QName qa = (pp.getAttributePrefix(i) == null) ? df
                                .createQName(pp.getAttributeName(i)) : df
                                .createQName(pp.getAttributeName(i), pp
                                        .getAttributePrefix(i), pp
                                        .getAttributeNamespace(i));
                        newElement.addAttribute(qa, pp.getAttributeValue(i));
                    }

                    if (parent != null) {
                        parent.add(newElement);
                    } else {
                        document.add(newElement);
                    }

                    parent = newElement;

                    break;
                }

                case XmlPullParser.END_TAG: {
                    if (parent != null) {
                        parent = parent.getParent();
                    }

                    break;
                }

                case XmlPullParser.TEXT: {
                    String text = pp.getText();

                    if (parent != null) {
                        parent.addText(text);
                    } else {
                        String msg = "Cannot have text content outside of the "
                                + "root document";
                        throw new DocumentException(msg);
                    }

                    break;
                }
View Full Code Here


        InputStream in = null;
        try {
            in = url.openStream();
            return reader.read(in);
        } catch (IOException e) {
            throw new DocumentException(e);
        } finally {
            try {in.close();} catch (Throwable t) {;}
        }
    }
View Full Code Here

/*  261 */         source.setSystemId(sb.toString());
/*      */       }
/*      */
/*  264 */       return read(source); } catch (FileNotFoundException e) {
/*      */     }
/*  266 */     throw new DocumentException(e.getMessage(), e);
/*      */   }
View Full Code Here

/*  475 */           systemId = "";
/*      */         }
/*      */
/*  478 */         String message = "Error on line " + parseException.getLineNumber() + " of document " + systemId + " : " + parseException.getMessage();
/*      */
/*  482 */         throw new DocumentException(message, e);
/*      */       }
/*      */     }
/*  484 */     throw new DocumentException(e.getMessage(), e);
/*      */   }
View Full Code Here

/*      */       else
/*  950 */         reader.setErrorHandler(handler);
/*      */     }
/*      */     catch (Exception e) {
/*  953 */       if (isValidating())
/*  954 */         throw new DocumentException("Validation not supported for XMLReader: " + reader, e);
/*      */     }
/*      */   }
View Full Code Here

/* 398 */         if (parent != null) {
/* 399 */           parent.addCDATA(pp.getText());
/*     */         } else {
/* 401 */           String msg = "Cannot have text content outside of the root document";
/*     */
/* 403 */           throw new DocumentException(msg);
/*     */         }
/*     */
/*     */       case 6:
/* 410 */         break;
/*     */       case 1:
/* 413 */         return document;
/*     */       case 2:
/* 416 */         QName qname = pp.getPrefix() == null ? df.createQName(pp.getName(), pp.getNamespace()) : df.createQName(pp.getName(), pp.getPrefix(), pp.getNamespace());
/*     */
/* 419 */         Element newElement = df.createElement(qname);
/* 420 */         int nsStart = pp.getNamespaceCount(pp.getDepth() - 1);
/* 421 */         int nsEnd = pp.getNamespaceCount(pp.getDepth());
/*     */
/* 423 */         for (int i = nsStart; i < nsEnd; i++) {
/* 424 */           if (pp.getNamespacePrefix(i) != null) {
/* 425 */             newElement.addNamespace(pp.getNamespacePrefix(i), pp.getNamespaceUri(i));
/*     */           }
/*     */
/*     */         }
/*     */
/* 430 */         for (int i = 0; i < pp.getAttributeCount(); i++) {
/* 431 */           QName qa = pp.getAttributePrefix(i) == null ? df.createQName(pp.getAttributeName(i)) : df.createQName(pp.getAttributeName(i), pp.getAttributePrefix(i), pp.getAttributeNamespace(i));
/*     */
/* 436 */           newElement.addAttribute(qa, pp.getAttributeValue(i));
/*     */         }
/*     */
/* 439 */         if (parent != null)
/* 440 */           parent.add(newElement);
/*     */         else {
/* 442 */           document.add(newElement);
/*     */         }
/*     */
/* 445 */         parent = newElement;
/*     */
/* 447 */         break;
/*     */       case 3:
/* 451 */         if (parent == null) break;
/* 452 */         parent = parent.getParent(); break;
/*     */       case 4:
/* 459 */         String text = pp.getText();
/*     */
/* 461 */         if (parent != null) {
/* 462 */           parent.addText(text);
/*     */         } else {
/* 464 */           String msg = "Cannot have text content outside of the root document";
/*     */
/* 466 */           throw new DocumentException(msg);
/*     */         }
/*     */       case 7:
/*     */       }
/*     */     }
/*     */   }
View Full Code Here

/* 164 */       Reader reader = new InputStreamReader(new FileInputStream(source), charset);
/*     */
/* 167 */       return installModifier().modify(reader);
/*     */     } catch (JAXBRuntimeException ex) {
/* 169 */       Throwable cause = ex.getCause();
/* 170 */       throw new DocumentException(cause.getMessage(), cause); } catch (FileNotFoundException ex) {
/*     */     }
/* 172 */     throw new DocumentException(ex.getMessage(), ex);
/*     */   }
View Full Code Here

/*     */     try
/*     */     {
/* 193 */       return installModifier().modify(source);
/*     */     } catch (JAXBRuntimeException ex) {
/* 195 */       cause = ex.getCause();
/* 196 */     }throw new DocumentException(cause.getMessage(), cause);
/*     */   }
View Full Code Here

/*     */     try
/*     */     {
/* 217 */       return installModifier().modify(source);
/*     */     } catch (JAXBRuntimeException ex) {
/* 219 */       cause = ex.getCause();
/* 220 */     }throw new DocumentException(cause.getMessage(), cause);
/*     */   }
View Full Code Here

/*     */     try
/*     */     {
/* 243 */       return installModifier().modify(source);
/*     */     } catch (JAXBRuntimeException ex) {
/* 245 */       cause = ex.getCause();
/* 246 */     }throw new DocumentException(cause.getMessage(), cause);
/*     */   }
View Full Code Here

TOP

Related Classes of org.dom4j.DocumentException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.