List of usage examples for org.dom4j QName QName
public QName(String name, Namespace namespace)
From source file:org.danann.cernunnos.xml.NodeProcessor.java
License:Apache License
/** * Recursively applies the specified <code>Namespace</code> to the specified * <code>Element</code>, unless the <code>Element</code> (or any child * <code>Element</code>) already specifies a <code>Namespace</code>. * * @param nsp Namespace to apply./* w w w. j a va 2s.c o m*/ * @param e XML structure upon which to apply the Namespace. */ public static void applyNamespace(Namespace nsp, Element e) { // Assertions... if (nsp == null) { String msg = "Argument 'nsp' cannot be null."; throw new IllegalArgumentException(msg); } if (e == null) { String msg = "Argument 'e [Element]' cannot be null."; throw new IllegalArgumentException(msg); } if (e.getNamespace().equals(Namespace.NO_NAMESPACE)) { e.setQName(new QName(e.getName(), nsp)); for (Object n : e.elements()) { applyNamespace(nsp, (Element) n); } } }
From source file:org.etudes.component.app.melete.MeleteAbstractExportServiceImpl.java
License:Apache License
/** * creates document root element "manifest" and adds the namespaces * * @return returns the manifest element//from w w w .j a v a 2 s .c o m * @throws Exception */ public Element createManifest() throws Exception { Element root = DocumentHelper.createElement("manifest"); //Set up the necessary namespaces root.setQName(new QName("manifest", new Namespace(null, DEFAULT_NAMESPACE_URI))); root.add(new Namespace("imsmd", getMetaDataNameSpace())); root.add(new Namespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")); /*root.addAttribute("xsi:schemaLocation", "http://www.imsglobal.org/xsd/imscp_v1p1 " + "http://www.imsglobal.org/xsd/imscp_v1p1.xsd " + "http://www.imsglobal.org/xsd/imsmd_v1p2 " + "http://www.imsglobal.org/xsd/imsmd_v1p2.xsd "); */ root.addAttribute("identifier", "Manifest-" + getUUID()); root.addAttribute("version", "IMS CP 1.1.4"); return root; }
From source file:org.etudes.component.app.melete.MeleteAbstractExportServiceImpl.java
License:Apache License
/** * creates the default namespace element * @param elename - element name/*from w w w . ja va 2 s . co m*/ * @param qname - qualified name * @return - returns the default namespace element */ public Element createDefaultNSElement(String elename, String qname) { Element metadata = DocumentHelper.createElement(elename); metadata.setQName(new QName(qname, new Namespace(null, DEFAULT_NAMESPACE_URI))); return metadata; }
From source file:org.etudes.component.app.melete.MeleteAbstractExportServiceImpl.java
License:Apache License
/** * creates the LOM metadata element// w ww . j a va 2s. com * @param elename - element name * @param qname - qualified name * @return - returns the metadata element */ public Element createLOMElement(String elename, String qname) { Element imsmdlom = DocumentHelper.createElement(elename); imsmdlom.setQName(new QName(qname, new Namespace("imsmd", getMetaDataNameSpace()))); return imsmdlom; }
From source file:org.etudes.jforum.view.admin.ImportExportAction.java
License:Apache License
/** * creates the default namespace element * /*from w ww.ja v a 2s. com*/ * @param elename * - element name * @param qname * - qualified name * @return - returns the default namespace element */ private Element createDefaultNSElement(String elename, String qname) { Element metadata = DocumentHelper.createElement(elename); metadata.setQName(new QName(qname, new Namespace(null, DEFAULT_NAMESPACE_URI))); return metadata; }
From source file:org.etudes.jforum.view.admin.ImportExportAction.java
License:Apache License
/** * creates the LOM metadata element/* ww w. jav a 2s. c o m*/ * * @param elename * - element name * @param qname * - qualified name * @return - returns the metadata element */ private Element createLOMElement(String elename, String qname) { Element imsmdlom = DocumentHelper.createElement(elename); imsmdlom.setQName(new QName(qname, new Namespace("imsmd", IMSMD_NAMESPACE_URI))); return imsmdlom; }
From source file:org.intalio.tempo.workflow.fds.dispatches.EscalateDispatcher.java
License:Open Source License
public Document dispatchRequest(Document request) throws InvalidInputFormatException { Namespace ns = new Namespace(NS_PREFIX, NS_URI); Element rootElement = request.getRootElement(); userProcessNamespace = rootElement.getNamespaceURI(); userProcessPrefix = rootElement.getNamespacePrefix(); List nodes = DocumentHelper.createXPath("//*").selectNodes(request); for (int i = 0; i < nodes.size(); ++i) { Element element = (Element) nodes.get(i); element.remove(element.getNamespaceForURI(userProcessNamespace)); element.setQName(new QName(element.getName(), ns)); }/* w w w . j a v a 2s .co m*/ rootElement.setQName(new QName("escalateTaskRequest", ns)); // TODO: fix this in VC! return request; }
From source file:org.intalio.tempo.workflow.fds.dispatches.EscalateDispatcher.java
License:Open Source License
public Document dispatchResponse(Document response) throws InvalidInputFormatException { // TODO: process the TMP response Namespace ns = new Namespace(userProcessPrefix, userProcessNamespace); response.getRootElement().setName("escalateResponse"); List nodes = DocumentHelper.createXPath("//*").selectNodes(response); for (int i = 0; i < nodes.size(); ++i) { Element element = (Element) nodes.get(i); element.remove(element.getNamespaceForURI(NS_URI)); element.setQName(new QName(element.getName(), ns)); }/* w ww .j av a2 s . co m*/ return response; }
From source file:org.intalio.tempo.workflow.fds.dispatches.NotifyDispatcher.java
License:Open Source License
public Document dispatchRequest(Document request) throws InvalidInputFormatException { Element rootElement = request.getRootElement(); userProcessNamespace = rootElement.getNamespaceURI(); Namespace ns = new Namespace("tms", TMS_NS); rootElement.setQName(new QName("createTaskRequest", ns)); Element metadataElement = rootElement.element("metadata"); metadataElement.setQName(new QName("metadata", ns)); metadataElement.detach();/* ww w .j a v a 2s . co m*/ Element taskElement = rootElement.addElement("task"); taskElement.setQName(new QName("task", ns)); taskElement.add(metadataElement); if (metadataElement.selectSingleNode("taskId") == null) { Element taskIdElement = metadataElement.addElement(new QName("taskId", ns)); taskIdElement.setText(generateUID()); } if (metadataElement.selectSingleNode("taskType") == null) { Element taskTypeElement = metadataElement.addElement(new QName("taskType", ns)); taskTypeElement.setText("NOTIFICATION"); } Element inputElement = rootElement.element("input"); inputElement.setQName(new QName("input", ns)); //inputElement.addNamespace("fe", userProcessNamespace); inputElement.detach(); taskElement.add(inputElement); //TODO remove from TMS. Not needed rootElement.addElement("participantToken"); /* * Now, change the namespace the * input, to TMS_NS. */ XPath xpath = DocumentHelper.createXPath("/tms:createTaskRequest/tms:task/tms:input//*"); HashMap map = MessageConstants._nsMap; map.put("tms", TMS_NS); xpath.setNamespaceURIs(MessageConstants._nsMap); List allTaskInputElements = xpath.selectNodes(request); xpath = DocumentHelper.createXPath("//*"); List allBody = xpath.selectNodes(request); int size = allBody.size(); LOG.debug(allTaskInputElements.size() + ":" + size); for (int i = 0; i < size; ++i) { Node node = (Node) allBody.get(i); if (!allTaskInputElements.contains(node)) { Element element = (Element) node; element.remove(element.getNamespaceForURI(userProcessNamespace)); element.setQName(new QName(element.getName(), ns)); } } return request; }
From source file:org.jasig.portal.layout.dlm.FragmentDefinition.java
License:Apache License
@Override public void toElement(org.dom4j.Element parent) { // Assertions. if (parent == null) { String msg = "Argument 'parent' cannot be null."; throw new IllegalArgumentException(msg); }/*from w w w. j a v a 2 s . co m*/ QName q = new QName("fragment", FragmentDefinition.NAMESPACE); org.dom4j.Element rslt = DocumentHelper.createElement(q); rslt.addAttribute("name", this.getName()); rslt.addAttribute("ownerID", this.getOwnerId()); rslt.addAttribute("precedence", Double.toString(this.getPrecedence())); rslt.addAttribute("description", this.getDescription()); // Serialize our children... for (Evaluator v : this.evaluators) { v.toElement(rslt); } parent.add(rslt); }