当前位置: 首页>>代码示例>>Java>>正文


Java DocumentHelper.createElement方法代码示例

本文整理汇总了Java中org.dom4j.DocumentHelper.createElement方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentHelper.createElement方法的具体用法?Java DocumentHelper.createElement怎么用?Java DocumentHelper.createElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.dom4j.DocumentHelper的用法示例。


在下文中一共展示了DocumentHelper.createElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rolesMapToElement

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
/**
 *  Description of the Method
 *
 *@return    Description of the Return Value
 */
private Element rolesMapToElement() {
	Element rolesElement = DocumentHelper.createElement("roles");
	if (!this.isAdminUser()) {
		for (Iterator i = this.getRoleMap().keySet().iterator(); i.hasNext(); ) {
			String collection = (String) i.next();

			// TODO - eliminate "default" collection. this can be removed after user files
			// for each User instance are written.

			Roles.Role role = this.getAssignedRole(collection);
			if (role != Roles.NO_ROLE) {
				Element roleElement = rolesElement.addElement("role");
				roleElement.addElement("rolename").setText(role.toString());
				roleElement.addElement("collection").setText(collection);

			}
		}
	}
	return rolesElement;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:26,代码来源:User.java

示例2: addAgent

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
public static void addAgent (String id) throws Exception {
	NdrRequest request = new NdrRequest ();
	request.setObjectType(NDRObjectType.AGENT);
	request.setVerb ("addAgent");
	
	Element identifier = DocumentHelper.createElement("identifier");
	identifier.setText (id);
	identifier.addAttribute ("type", "HOST");
	request.addCommand ("property", identifier);
	request.addCommand ("relationship", "memberOf", "2200/test.20070806193858997T");
	String title = "Agent for mud collection";
	String description = "its all about mud";
	String subject = "none that i can see";
	NsdlDcWriter dc_stream = new NsdlDcWriter(title, description, subject);
	
	request.addDCStreamCmd(dc_stream.asElement());
	
	request.submit();
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:20,代码来源:DevelTools.java

示例3: getConfig

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
@Override
public Element getConfig() {
    final File boardFile = new File(getConfigFile());
    if (boardFile.exists()) {
        try {
            return new SAXReader(false).read(boardFile).getRootElement();
        } catch (DocumentException ex) {
            QLog.l().logger()
                .error("Невозможно прочитать файл конфигурации главного табло. " + ex
                    .getMessage());
            return DocumentHelper.createElement("Ответ");
        }
    } else {
        QLog.l().logger()
            .warn("Файл конфигурации главного табло \"" + configFile + "\" не найден. ");
        return DocumentHelper.createElement("Ответ");
    }
}
 
开发者ID:bcgov,项目名称:sbc-qsystem,代码行数:19,代码来源:QIndicatorBoardMonitor.java

示例4: setIdentifier

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
/**
 *  Sets the identifier attribute of the AddResourceRequest object
 *
 * @param  id    The new identifier value
 * @param  type  The new identifier value
 */
public void setIdentifier(String id, String type) {
	Element identifier = DocumentHelper.createElement("identifier");
	identifier.setText(id);
	if (type != null)
		identifier.addAttribute("type", type);
	this.addCommand("property", identifier);
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:14,代码来源:AddResourceRequest.java

示例5: setId

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
public void setId (String id, String type)  {

		Element identifier = DocumentHelper.createElement("identifier");
		identifier.setText (id);
		identifier.addAttribute ("type", type);
		this.addCommand ("property", identifier);
	}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:8,代码来源:AddAgentRequest.java

示例6: prefMapToElement

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
/**
 *  Description of the Method
 *
 *@return    Description of the Return Value
 */
private Element prefMapToElement() {
	Element prefrencesElement = DocumentHelper.createElement("preferences");
	for (Iterator i = this.getPrefMap().keySet().iterator(); i.hasNext(); ) {
		String prefname = (String) i.next();
		Element prefElement = prefrencesElement.addElement("pref");
		prefElement.addElement("prefname").setText(prefname);
		prefElement.addElement("prefvalue").setText(this.getPref(prefname));
	}
	return prefrencesElement;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:16,代码来源:User.java

示例7: serializeAsXml

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
public String serializeAsXml(T body) {
  Class<?> clazz = body.getClass();
  Element rootElement = DocumentHelper
      .createElement(clazz.getAnnotation(XmlRootElement.class).name());
  Document document = DocumentHelper.createDocument(rootElement);
  checkRequestPropertyValidAndAddElement(rootElement, body);
  printXML(document);
  return rootElement.asXML();
}
 
开发者ID:minlia-projects,项目名称:minlia-iot,代码行数:10,代码来源:AbstractAnnotationApiSerializer.java

示例8: handleGeneralProxy

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
private ActionForward handleGeneralProxy(ActionMapping mapping,
                                         ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response) throws Exception {
	NDRForm ndrForm = (NDRForm) form;
	prtln("processing general proxy");
	ndrForm.setProxyResponse("");
	String uri = request.getParameter("uri");
	if (uri == null || uri.trim().length() == 0)
		throw new Exception("proxy handler did not receive a URI");

	prtln("\t uri: " + uri);
	String format = request.getParameter("format");
	if (format == null)
		format = "json";
	Document responseDoc = null;
	try {
		responseDoc = Dom4jUtils.getXmlDocument(new URL(uri));
		// prtln("\n RAW RESPONSE");
		// prtln (doc.asXML());
	} catch (Exception e) {
		String errMsg = "proxy response error: " + e.getMessage();
		prtlnErr(errMsg);
		// e.printStackTrace();
		Element error = DocumentHelper.createElement("ProxyErrorReport");
		error.setText(errMsg);
		responseDoc = DocumentHelper.createDocument(error);
	}

	if (format.equals("json")) {
		JSONObject json = XML.toJSONObject(responseDoc.asXML());
		// prtln(json.toString(2));
		ndrForm.setProxyResponse(json.toString());
	}
	else if (format.equals("xml")) {
		// prtln (Dom4jUtils.prettyPrint(responseDoc));
		ndrForm.setProxyResponse(responseDoc.asXML());
	}
	else {
		throw new Exception("unrecognized format: " + format);
	}
	
	return mapping.findForward("proxy.response");
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:45,代码来源:NDRAction.java

示例9: getRepeatingContentBox

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
/**
 *  Create a "box" for the contents of each repitition of this node, which is
 *  filled by the subclasses which build upon this method.
 *
 * @param  itemPath  xpath with indexing to support iteration
 * @return           The repeatingContentBox value
 */
protected Element getRepeatingContentBox(String itemPath) {
	Element repeatingContent = DocumentHelper.createElement("div");

	/* 	the following works because "itemPath" has been defined in the jsp
		(see getIteration) prior to the repeating repeatingContent
	*/
	repeatingContent.addAttribute("id", "${sf__pathToId(itemPath)}_box");

	return repeatingContent;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:18,代码来源:MdeRepeatingNode.java

示例10: newSiblingController

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
/**
 *  Create new item controller that goes at the bottom of a repeating node to
 *  allow user to create a new element (sibling). <p>
 *
 *  This controller is not displayed in the case when the parent element is
 *  empty. In that case, the new item control is displayed with the parent
 *  element.
 *
 * @return    Control element to add a new sibling to this repeating node.
 */
public Element newSiblingController() {

	String siblingPath = XPathUtils.getSiblingXPath(xpath);
	String childName = XPathUtils.getNodeName(siblingPath);
	String indexId = RendererHelper.encodeIndexId(siblingPath);
	String itemPath = siblingPath + "_${" + indexId + "+1}_";

	Element controllerBox = DocumentHelper.createElement("div");
	// new sibling control only displayed when there are already members (i.e., siblings!)
	Element hasMembersTest = rhelper.nodeHasMembersTest(itemPath);
	controllerBox.add(hasMembersTest);

	Element newItemControl = rhelper.acceptsNewSiblingTest(itemPath);

	Element actionBox = newItemControl.addElement("div")
		.addAttribute("style", "width:100px;text-align:center");

	Element style = actionBox.addElement("div")
		.addAttribute("class", "action-button");
	Element newItemLink = style.addElement("a")
		.addAttribute("href", "javascript:doNewElement(" + rhelper.jspQuotedString(itemPath) + ")");
	rhelper.attachToolHelp(newItemLink, "Create a new " + childName);
	newItemLink.setText("add " + childName);

	if (newItemControl != null)
		hasMembersTest.add(newItemControl);

	return controllerBox;
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:40,代码来源:MdeRepeatingNode.java

示例11: makeJsonError

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
private String makeJsonError (String msg) {
	Element err = DocumentHelper.createElement ("error");
	if (msg == null)
		msg = "unknown error";
	err.setText(msg);
	Document responseDoc = DocumentHelper.createDocument(err);
	try {
		org.json.JSONObject json = org.json.XML.toJSONObject(responseDoc.asXML());
		return json.toString();
	} catch (Throwable e) {
		prtlnErr ("WARNING: unable to construct json error structure");
	}
		
	return "error"; 
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:16,代码来源:DCSSchemEditAction.java

示例12: addSiblingNodeTest

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
@Test
public void addSiblingNodeTest() throws IOException, SAXException, TransformerException {
    Document doc = DocumentHelper.createDocument(DocumentHelper.createElement("root"));

    Element root = doc.getRootElement();

    Element child = DocumentHelper.createElement("child");
    child.setText("test value 1");

    root.add(child);

    xmlBuilder.addNode(doc, "/root/child", "test value 2", uris.get("ARCLIB"));
    assertThat(doc.asXML(), is("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<root><child>test value 1</child><child xmlns=\"http://arclib.lib.cas.cz/ARCLIB_XML\">test value 2</child></root>"));
}
 
开发者ID:LIBCAS,项目名称:ARCLib,代码行数:15,代码来源:XmlBuilderTest.java

示例13: main

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
public static void main(String args[]){

		Namespace rootNs = new Namespace("", "uri:oozie:workflow:0.4"); // root namespace uri
		QName rootQName = QName.get("workflow-app", rootNs); // your root element's name
		Element workflow = DocumentHelper.createElement(rootQName);
		Document doc = DocumentHelper.createDocument(workflow);
		
		workflow.addAttribute("name", "test");
		Element test = workflow.addElement("test");
		test.addText("hello");
				OutputFormat outputFormat = OutputFormat.createPrettyPrint();
				outputFormat.setEncoding("UTF-8");
				outputFormat.setIndent(true); 
				outputFormat.setIndent("    "); 
				outputFormat.setNewlines(true); 
		try {
			StringWriter stringWriter = new StringWriter();
			XMLWriter xmlWriter = new XMLWriter(stringWriter);
			xmlWriter.write(doc);
			xmlWriter.close();
			System.out.println( doc.asXML() );
			System.out.println( stringWriter.toString().trim());

		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:28,代码来源:WFGraph.java

示例14: XmlText

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
private XmlText( Element root ) throws XMLException {
    this.root = DocumentHelper.createElement("root");

    DocumentHelper.createDocument(this.root);

    this.root = root.createCopy();

    DocumentHelper.createDocument(this.root);
}
 
开发者ID:Axway,项目名称:ats-framework,代码行数:10,代码来源:XmlText.java

示例15: getMeta

import org.dom4j.DocumentHelper; //导入方法依赖的package包/类
public String getMeta (String _format) {
	Element meta = DocumentHelper.createElement ("meta");
	meta.add(this.getDataStream( _format).createCopy());
	return meta.asXML();
}
 
开发者ID:NCAR,项目名称:joai-project,代码行数:6,代码来源:DataStreamWrapper.java


注:本文中的org.dom4j.DocumentHelper.createElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。