Refine search
Document doc = DocumentFactory.getInstance().createDocument(); generatedModel = coreModel.createCopy(); doc.add(generatedModel); Element appName = (Element)element.selectSingleNode("//adminconsole/global/appname"); if (appName != null) { Element existingAppName = (Element)generatedModel.selectSingleNode( "//adminconsole/global/appname"); existingAppName.setText(appName.getText());
public Document parseDocument() throws DocumentException, IOException, XmlPullParserException { DocumentFactory df = getDocumentFactory(); Document document = df.createDocument(); Element parent = null; XmlPullParser pp = getXPPParser(); document.addProcessingInstruction(text, ""); parent.addComment(pp.getText()); document.addComment(pp.getText()); String text = pp.getText(); if (parent != null) { parent.addCDATA(text); String text = pp.getText(); if (parent != null) { parent.addText(text); QName qname = (pp.getPrefix() == null) ? df.createQName(pp.getName(), pp.getNamespace()) : df.createQName(pp.getName(), pp.getPrefix(), pp.getNamespace()); Element newElement; newElement = df.createElement(pp.getName()); newElement = df.createElement(qname); 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));
/** * Convert the BugCollection into a dom4j Document object. * * @return the Document representing the BugCollection as a dom4j tree */ @Override public Document toDocument() { // if (project == null) throw new NullPointerException("No project"); assert project != null; DocumentFactory docFactory = new DocumentFactory(); Document document = docFactory.createDocument(); Dom4JXMLOutput treeBuilder = new Dom4JXMLOutput(document); try { writeXML(treeBuilder); } catch (IOException e) { // Can't happen } return document; }
protected Document documentRoot() throws Exception { CruiseConfig cruiseConfig = goConfigDao.loadForEditing(); ByteArrayOutputStream out = new ByteArrayOutputStream(); new MagicalGoConfigXmlWriter(configCache, registry).write(cruiseConfig, out, true); Document document = reader.read(new StringReader(out.toString())); Map<String, String> map = new HashMap<>(); map.put("go", MagicalGoConfigXmlWriter.XML_NS); //TODO: verify this doesn't cache the factory DocumentFactory factory = DocumentFactory.getInstance(); factory.setXPathNamespaceURIs(map); return document; }
/** * Returns an Element with the privacy list XML representation. * * @return an Element with the privacy list XML representation. */ public Element asElement() { //Element listElement = DocumentFactory.getInstance().createDocument().addElement("list"); Element listElement = DocumentFactory.getInstance().createDocument() .addElement("list", "jabber:iq:privacy"); listElement.addAttribute("name", getName()); // Add the list items to the result for (PrivacyItem item : items) { listElement.add(item.asElement()); } return listElement; }
private Document createDocument(final Reflections reflections) { Store map = reflections.getStore(); Document document = DocumentFactory.getInstance().createDocument(); Element root = document.addElement("Reflections"); for (String indexName : map.keySet()) { Element indexElement = root.addElement(indexName); for (String key : map.get(indexName).keySet()) { Element entryElement = indexElement.addElement("entry"); entryElement.addElement("key").setText(key); Element valuesElement = entryElement.addElement("values"); for (String value : map.get(indexName).get(key)) { valuesElement.addElement("value").setText(value); } } } return document; } }
@Override void getChildren(Object node, String localName, String namespaceUri, List result) { if (node instanceof Element) { Element e = (Element) node; if (localName == null) { result.addAll(e.elements()); } else { result.addAll(e.elements(e.getQName().getDocumentFactory().createQName(localName, "", namespaceUri))); } } else if (node instanceof Document) { Element root = ((Document) node).getRootElement(); if (localName == null || (equal(root.getName(), localName) && equal(root.getNamespaceURI(), namespaceUri))) { result.add(root); } } }
public void testEscapeXML() throws Exception { ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputFormat format = new OutputFormat(null, false, "ISO-8859-2"); format.setSuppressDeclaration(true); XMLWriter writer = new XMLWriter(os, format); Document document = DocumentFactory.getInstance().createDocument(); Element root = document.addElement("root"); root.setText("bla &#c bla"); writer.write(document); String result = os.toString(); System.out.println(result); Document doc2 = DocumentHelper.parseText(result); doc2.normalize(); // merges adjacant Text nodes System.out.println(doc2.getRootElement().getText()); assertNodesEqual(document, doc2); }
private String getServerUpdateRequest() { XMPPServer server = XMPPServer.getInstance(); Element xmlRequest = docFactory.createDocument().addElement("version"); // Add current openfire version Element openfire = xmlRequest.addElement("openfire"); openfire.addAttribute("current", server.getServerInfo().getVersion().getVersionString()); return xmlRequest.asXML(); }
if ( defaultPrivacyList == null ) final Element listElement = DocumentFactory.getInstance().createDocument().addElement( "list", "jabber:iq:privacy" ); listElement.addAttribute( "name", "blocklist" ); for ( int i = 0; i < toBlocks.size(); i++ ) final Element element = DocumentHelper.createElement( "item" ) .addAttribute( "type", "jid" ) .addAttribute( "value", toBlocks.get( i ).toString() ) .addAttribute( "action", "deny" ) .addAttribute( "order", Integer.toString( i ) );
public void testBug569927() { Document doc = DocumentHelper.createDocument(); QName elName = DocumentFactory.getInstance().createQName("a", "ns", "uri://myuri"); Element a = doc.addElement(elName); QName attName = DocumentFactory.getInstance().createQName("attribute", "ns", "uri://myuri"); a = a.addAttribute(attName, "test"); Attribute att = a.attribute(attName); assertSame(att, doc.selectSingleNode(att.getPath())); assertSame(att, doc.selectSingleNode(att.getUniquePath())); }
private String getAvailablePluginsUpdateRequest() { Element xmlRequest = docFactory.createDocument().addElement("available"); // Add locale so we can get current name and description of plugins Element locale = xmlRequest.addElement("locale"); locale.addText(JiveGlobals.getLocale().toString()); return xmlRequest.asXML(); }
public void testBug799656() throws Exception { Document document = DocumentFactory.getInstance().createDocument(); Element el = document.addElement("root"); el.setText("text with an \u00FC in it"); // u00FC is umlaut System.out.println(document.asXML()); DocumentHelper.parseText(document.asXML()); }
/** * Constructs a new Route. * * @param streamID the stream ID that identifies the connection that is actually sending * the wrapped stanza. */ public Route(StreamID streamID) { this.element = docFactory.createDocument().addElement("route"); // Set the stream ID that identifies the target session element.addAttribute("streamid", streamID.getID()); }
XPath xExclude = dom.createXPath(exclude); xExclude.setFunctionContext(functionContext); List<org.dom4j.Node> list = (List<org.dom4j.Node>)xExclude.selectNodes(dom); Element parent = n.getParent(); if(parent!=null) parent.remove(n); result = dom; } else { XPath comp = dom.createXPath(xpath); comp.setFunctionContext(functionContext); List list = comp.selectNodes(dom); Element root = DocumentFactory.getInstance().createElement(wrapper); for (Object o : list) { if (o instanceof String) { root.addText(o.toString()); } else { root.add(((org.dom4j.Node)o).detach());
public AuditPacket(Packet packet, Session session) { element = docFactory.createElement("packet", "http://www.jivesoftware.org"); creationDate = new Date(); if (session != null && session.getStreamID() != null) { element.addAttribute("streamID", session.getStreamID().toString()); } switch (session == null ? 0 : session.getStatus()) { case Session.STATUS_AUTHENTICATED: element.addAttribute("status", "auth"); break; case Session.STATUS_CLOSED: element.addAttribute("status", "closed"); break; case Session.STATUS_CONNECTED: element.addAttribute("status", "connected"); // This is a workaround. Since we don't want to have an incorrect FROM attribute // value we need to clean up the FROM attribute. The FROM attribute will contain // an incorrect value since we are setting a fake JID until the user actually // authenticates with the server. packet.setFrom((String) null); break; default: element.addAttribute("status", "unknown"); break; } element.addAttribute("timestamp", auditFormat.format(creationDate)); element.add(packet.getElement()); }
public void testDocument() throws Exception { DocumentFactory factory = new DocumentFactory(); Element root = factory.createElement("root"); Element first = root.addElement("child"); first.addText("This is some text"); assertTrue("Root node is not text only: " + root, !root.isTextOnly()); assertTrue("First child is text only: " + first, first.isTextOnly()); } }
Element e = (Element) node; if (localName == null) { result.addAll(e.attributes()); } else { Attribute attr = e.attribute(e.getQName().getDocumentFactory().createQName(localName, "", namespaceUri)); if (attr != null) { result.add(attr);
public void testFragment() throws Exception { DocumentFactory factory = new DocumentFactory(); Element root = factory.createElement("root"); Element first = root.addElement("child"); Element second = root.addElement("child"); testXPathNode(root, first); testXPathNode(root, second); }
private Document generateDefaultRevisionInfoXmlMapping() { final Document document = globalCfg.getEnversService().getXmlHelper().getDocumentFactory().createDocument(); ); classMapping.addAttribute( "name", revisionInfoEntityName ); classMapping.addAttribute( "table", "REVINFO" );