Refine search
protected Object createNode(final String name) { final Element element = documentFactory.element(encodeNode(name)); final Element parent = top(); if (parent != null) { parent.addContent(element); } return element; }
public void addAttribute(final String key, final String value) { top().setAttribute(documentFactory.attribute(encodeAttribute(key), value)); }
public void setValue(final String text) { top().addContent(documentFactory.text(text)); }
child = f.cdata(r.getText()); break; child = f.text(r.getText()); break; child = f.comment(r.getText()); break; child = f.entityRef(r.getLocalName()); break; child = f.processingInstruction(r.getPITarget(), r.getPIData()); break; newElem = f.element(ln); } else { newElem = f.element(ln, elemPrefix, ""); newElem = f.element(ln, elemPrefix, nsURI); f.addContent(current, newElem); f.addNamespaceDeclaration(newElem, ns); Attribute attr = f.attribute(r.getAttributeLocalName(i), r.getAttributeValue(i), resolveAttrType(r.getAttributeType(i)), ns); f.setAttribute(newElem, attr);
Element element = factory.element(localName, ns); factory.addContent(current, element); factory.addNamespaceDeclaration(element, declaredNS); factory.attribute(attLocalName, attvalue, attNS); factory.setAttribute(element, attribute); 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())); EntityRef entity = factory.entityRef(node.getNodeName()); factory.addContent(current, entity);
Element element = factory.element(localName, namespace); factory.addContent(getCurrentElement(), element); if (p.getNamespace().getURI().equals(attURI) && !overrides.contains(p.getNamespacePrefix()) && !"".equals(element.getNamespace().getPrefix())) { Attribute attribute = factory.attribute(attLocalName, attValue, attType, attNs); factory.setAttribute(element, attribute);
factory.addContent(getCurrentElement(), factory.cdata(data)); factory.addContent(getCurrentElement(), factory.text(data));
/** * This will build a JDOM Element from an existing DOM Element * * @param domElement <code> org.w3c.dom.Element</code> object * @return <code>Element</code> - JDOM Element object */ public org.jdom.Element build(org.w3c.dom.Element domElement) { Document doc = factory.document(null); buildTree(domElement, doc, null, true); return doc.getRootElement(); }
/** * 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)); }
/** * 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)); } }
/** * 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 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; }
/** * 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; }
child = f.cdata(r.getText()); break; child = f.text(r.getText()); break; child = f.comment(r.getText()); break; child = f.entityRef(r.getLocalName()); break; child = f.processingInstruction(r.getPITarget(), r.getPIData()); break; newElem = f.element(ln); } else { newElem = f.element(ln, elemPrefix, ""); newElem = f.element(ln, elemPrefix, nsURI); f.addContent(current, newElem); f.addNamespaceDeclaration(newElem, ns); Attribute attr = f.attribute(r.getAttributeLocalName(i), r.getAttributeValue(i), resolveAttrType(r.getAttributeType(i)), ns); f.setAttribute(newElem, attr);
/** * This will build a JDOM tree from an existing DOM tree. * * @param domDocument <code>org.w3c.dom.Document</code> object * @return <code>Document</code> - JDOM document object. */ public Document build(org.w3c.dom.Document domDocument) { Document doc = factory.document(null); buildTree(domDocument, doc, null, true); return doc; }
EntityRef entity = factory.entityRef(name, pub, sys); factory.addContent(getCurrentElement(), entity);
@Override protected Element createNode(final String name) { final Element element = documentFactory.element(encodeNode(name)); final Element parent = top(); if (parent != null) { parent.addContent(element); } return element; }
@Override public void setValue(final String text) { top().addContent(documentFactory.text(text)); }