/** * Pushes an element onto the tree under construction. Allows subclasses * to put content under a dummy root element which is useful for building * content that would otherwise be a non-well formed document. * * @param element root element under which content will be built */ protected void pushElement(Element element) { if (atRoot) { document.setRootElement(element); // XXX should we use a factory call? atRoot = false; } else { factory.addContent(currentElement, element); } currentElement = element; }
/** * This will signify that a DTD is being parsed, and can be * used to ensure that comments and other lexical structures * in the DTD are not added to the JDOM <code>Document</code> * object. * * @param name <code>String</code> name of element listed in DTD * @param publicID <code>String</code> public ID of DTD * @param systemID <code>String</code> system ID of DTD */ public void startDTD(String name, String publicID, String systemID) throws SAXException { flushCharacters(); // Is this needed here? factory.addContent(document, factory.docType(name, publicID, systemID)); inDTD = true; inInternalSubset = true; }
/** * This reports that a comments is parsed. If not in the * DTD, this comment is added to the current JDOM * <code>Element</code>, or the <code>Document</code> itself * if at that level. * * @param ch <code>ch[]</code> array of comment characters. * @param start <code>int</code> index to start reading from. * @param length <code>int</code> length of data. * @throws SAXException */ public void comment(char[] ch, int start, int length) throws SAXException { if (suppress) return; flushCharacters(); String commentText = new String(ch, start, length); if (inDTD && inInternalSubset && (expand == false)) { internalSubset.append(" <!--") .append(commentText) .append("-->\n"); return; } if ((!inDTD) && (!commentText.equals(""))) { if (atRoot) { factory.addContent(document, factory.comment(commentText)); } else { factory.addContent(getCurrentElement(), factory.comment(commentText)); } } }
/** * This indicates that an unresolvable entity reference has been * encountered, normally because the external DTD subset has not been * read. * * @param name <code>String</code> name of entity * @throws SAXException when things go wrong */ public void skippedEntity(String name) throws SAXException { // We don't handle parameter entity references. if (name.startsWith("%")) return; flushCharacters(); factory.addContent(getCurrentElement(), factory.entityRef(name)); }
factory.addContent(getCurrentElement(), factory.cdata(data)); factory.addContent(getCurrentElement(), factory.text(data));
/** * This will indicate that a processing instruction has been encountered. * (The XML declaration is not a processing instruction and will not * be reported.) * * @param target <code>String</code> target of PI * @param data <code>String</code> containing all data sent to the PI. * This typically looks like one or more attribute value * pairs. * @throws SAXException when things go wrong */ public void processingInstruction(String target, String data) throws SAXException { if (suppress) return; flushCharacters(); if (atRoot) { factory.addContent(document, factory.processingInstruction(target, data)); } else { factory.addContent(getCurrentElement(), factory.processingInstruction(target, data)); } }
factory.addContent(getCurrentElement(), entity);
factory.addContent(current, element); factory.addContent(current, factory.text(data)); break; factory.addContent(current, factory.cdata(cdata)); break; factory.addContent(doc, factory.processingInstruction(node.getNodeName(), node.getNodeValue())); } else { factory.addContent(current, factory.processingInstruction(node.getNodeName(), node.getNodeValue())); factory.addContent(doc, factory.comment(node.getNodeValue())); } else { factory.addContent(current, factory.comment(node.getNodeValue())); factory.addContent(current, entity); break; docType.setInternalSubset(internalDTD); factory.addContent(doc, docType); break;
factory.addContent(getCurrentElement(), element);
f.addContent(current, newElem); f.addContent(doc, child); } else { f.addContent(current, child);
f.addContent(current, newElem); f.addContent(doc, child); } else { f.addContent(current, child);
f.addContent(current, newElem); f.addContent(doc, child); f.addContent(current, child);
f.addContent(current, f.text(txt)); doc.setRootElement(newElem); } else { f.addContent(current, newElem); f.addContent(doc, child); } else { f.addContent(current, child);