예제 #1
1
 public void toXhtml(ContentHandler contentHandler, LexicalHandler lexicalHandler)
     throws PageTemplateException, SAXException {
   if (dom == null) {
     parseFragment();
   }
   SAXWriter writer = new SAXWriter(contentHandler, lexicalHandler);
   for (Iterator i = dom.nodeIterator(); i.hasNext(); ) {
     Node node = (Node) i.next();
     writer.write(node);
   }
 }
예제 #2
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /* 175:    */
 /* 176:    */ public void write(CDATA cdata) /* 177:    */ throws SAXException /* 178:    */ {
   /* 179:277 */ String text = cdata.getText();
   /* 180:279 */ if (this.lexicalHandler != null)
   /* 181:    */ {
     /* 182:280 */ this.lexicalHandler.startCDATA();
     /* 183:281 */ write(text);
     /* 184:282 */ this.lexicalHandler.endCDATA();
     /* 185:    */ }
   /* 186:    */ else
   /* 187:    */ {
     /* 188:284 */ write(text);
     /* 189:    */ }
   /* 190:    */ }
예제 #3
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /* 202:    */
 /* 203:    */ public void write(Entity entity) /* 204:    */ throws SAXException /* 205:    */ {
   /* 206:315 */ String text = entity.getText();
   /* 207:317 */ if (this.lexicalHandler != null)
   /* 208:    */ {
     /* 209:318 */ String name = entity.getName();
     /* 210:319 */ this.lexicalHandler.startEntity(name);
     /* 211:320 */ write(text);
     /* 212:321 */ this.lexicalHandler.endEntity(name);
     /* 213:    */ }
   /* 214:    */ else
   /* 215:    */ {
     /* 216:323 */ write(text);
     /* 217:    */ }
   /* 218:    */ }
예제 #4
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /*  78:    */
 /*  79:    */ public void write(Node node) /*  80:    */ throws SAXException /*  81:    */ {
   /*  82:125 */ int nodeType = node.getNodeType();
   /*  83:127 */ switch (nodeType)
   /*  84:    */ {
       /*  85:    */ case 1:
       /*  86:129 */ write((Element) node);
       /*  87:    */
       /*  88:131 */ break;
       /*  89:    */ case 2:
       /*  90:134 */ write((Attribute) node);
       /*  91:    */
       /*  92:136 */ break;
       /*  93:    */ case 3:
       /*  94:139 */ write(node.getText());
       /*  95:    */
       /*  96:141 */ break;
       /*  97:    */ case 4:
       /*  98:144 */ write((CDATA) node);
       /*  99:    */
       /* 100:146 */ break;
       /* 101:    */ case 5:
       /* 102:149 */ write((Entity) node);
       /* 103:    */
       /* 104:151 */ break;
       /* 105:    */ case 7:
       /* 106:154 */ write((ProcessingInstruction) node);
       /* 107:    */
       /* 108:156 */ break;
       /* 109:    */ case 8:
       /* 110:159 */ write((Comment) node);
       /* 111:    */
       /* 112:161 */ break;
       /* 113:    */ case 9:
       /* 114:164 */ write((Document) node);
       /* 115:    */
       /* 116:166 */ break;
       /* 117:    */ case 10:
       /* 118:169 */ write((DocumentType) node);
       /* 119:    */
       /* 120:171 */ break;
       /* 121:    */ case 13:
       /* 122:    */ break;
       /* 123:    */ case 6:
       /* 124:    */ case 11:
       /* 125:    */ case 12:
       /* 126:    */ default:
       /* 127:180 */ throw new SAXException("Invalid node type: " + node);
       /* 128:    */ }
   /* 129:    */ }
예제 #5
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /* 349:    */
 /* 350:    */ public void parse(InputSource input) /* 351:    */ throws SAXException
       /* 352:    */ {
   /* 353:600 */ if ((input instanceof DocumentInputSource))
   /* 354:    */ {
     /* 355:601 */ DocumentInputSource documentInput = (DocumentInputSource) input;
     /* 356:602 */ Document document = documentInput.getDocument();
     /* 357:603 */ write(document);
     /* 358:    */ }
   /* 359:    */ else
   /* 360:    */ {
     /* 361:605 */ throw new SAXNotSupportedException(
         "This XMLReader can only accept <dom4j> InputSource objects");
     /* 362:    */ }
   /* 363:    */ }
예제 #6
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /* 364:    */
 /* 365:    */ protected void writeContent(Branch branch, NamespaceStack namespaceStack)
     /* 366:    */ throws SAXException
       /* 367:    */ {
   /* 368:615 */ for (Iterator iter = branch.nodeIterator(); iter.hasNext(); )
   /* 369:    */ {
     /* 370:616 */ Object object = iter.next();
     /* 371:618 */ if ((object instanceof Element)) {
       /* 372:619 */ write((Element) object, namespaceStack);
       /* 373:620 */ } else if ((object instanceof CharacterData))
     /* 374:    */ {
       /* 375:621 */ if ((object instanceof Text))
       /* 376:    */ {
         /* 377:622 */ Text text = (Text) object;
         /* 378:623 */ write(text.getText());
         /* 379:    */ }
       /* 380:624 */ else if ((object instanceof CDATA))
       /* 381:    */ {
         /* 382:625 */ write((CDATA) object);
         /* 383:    */ }
       /* 384:626 */ else if ((object instanceof Comment))
       /* 385:    */ {
         /* 386:627 */ write((Comment) object);
         /* 387:    */ }
       /* 388:    */ else
       /* 389:    */ {
         /* 390:629 */ throw new SAXException(
             "Invalid Node in DOM4J content: " + object + " of type: " + object.getClass());
         /* 391:    */ }
       /* 392:    */ }
     /* 393:632 */ else if ((object instanceof String)) {
       /* 394:633 */ write((String) object);
       /* 395:634 */ } else if ((object instanceof Entity)) {
       /* 396:635 */ write((Entity) object);
       /* 397:636 */ } else if ((object instanceof ProcessingInstruction)) {
       /* 398:637 */ write((ProcessingInstruction) object);
       /* 399:638 */ } else if ((object instanceof Namespace)) {
       /* 400:639 */ write((Namespace) object);
       /* 401:    */ } else {
       /* 402:641 */ throw new SAXException("Invalid Node in DOM4J content: " + object);
       /* 403:    */ }
     /* 404:    */ }
   /* 405:    */ }
예제 #7
0
 public void readSAXfromDOM4J(
     Document doc, ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException {
   SAXWriter writer = new SAXWriter(contentHandler);
   writer.setErrorHandler(errorHandler);
   writer.write(doc);
 }
예제 #8
0
파일: SAXWriter.java 프로젝트: enenuki/phd
 /* 147:    */
 /* 148:    */ public void write(Element element) /* 149:    */ throws SAXException /* 150:    */ {
   /* 151:217 */ write(element, new NamespaceStack());
   /* 152:    */ }