List of usage examples for org.dom4j XPath setNamespaceURIs
void setNamespaceURIs(Map<String, String> map);
From source file:eu.scape_project.planning.services.taverna.parser.T2FlowParser.java
License:Apache License
/** * Reads the name annotation of the t2flow. * //from w w w . j av a 2 s . c om * @return the name of the workflow * @throws TavernaParserException */ public String getName() throws TavernaParserException { log.debug("Extracting workflow name"); XPath xpath = DocumentHelper.createXPath( "/t2f:workflow/t2f:dataflow[@role='top']/t2f:annotations/*/*/*/*/annotationBean[@class='net.sf.taverna.t2.annotation.annotationbeans.DescriptiveTitle']/text"); xpath.setNamespaceURIs(T2FLOW_NAMESPACE_MAP); Node node = xpath.selectSingleNode(doc); if (node == null) { return null; } return node.getText(); }
From source file:eu.scape_project.planning.services.taverna.parser.T2FlowParser.java
License:Apache License
/** * Reads the description annotation of the t2flow. * /*from www . ja v a 2 s . co m*/ * @return the description of the workflow * @throws TavernaParserException */ public String getDescription() throws TavernaParserException { log.debug("Extracting workflow description"); XPath xpath = DocumentHelper.createXPath( "/t2f:workflow/t2f:dataflow[@role='top']/t2f:annotations/*/*/*/*/annotationBean[@class='net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription']/text"); xpath.setNamespaceURIs(T2FLOW_NAMESPACE_MAP); Node node = xpath.selectSingleNode(doc); if (node == null) { return null; } return node.getText(); }
From source file:eu.scape_project.planning.services.taverna.parser.T2FlowParser.java
License:Apache License
/** * Reads the author annotation of the t2flow. * /* w w w . j av a 2s . c o m*/ * @return the author of the workflow * @throws TavernaParserException */ public String getAuthor() throws TavernaParserException { log.debug("Extracting workflow author"); XPath xpath = DocumentHelper.createXPath( "/t2f:workflow/t2f:dataflow[@role='top']/t2f:annotations/*/*/*/*/annotationBean[@class='net.sf.taverna.t2.annotation.annotationbeans.Author']/text"); xpath.setNamespaceURIs(T2FLOW_NAMESPACE_MAP); Node node = xpath.selectSingleNode(doc); if (node == null) { return null; } return node.getText(); }
From source file:eu.scape_project.planning.xml.ProjectExportAction.java
License:Apache License
/** * Returns a list of object IDs that are stored in the document without * binary data.// ww w . jav a 2s . co m * * @param doc * the document to search * @return a list of IDs */ private List<Integer> getBinaryObjectIds(Document doc) { // Get data elements that have data and a number as content XPath xpath = doc.createXPath("//plato:data[@hasData='true' and number(.) = number(.)]"); Map<String, String> namespaceMap = new HashMap<String, String>(); namespaceMap.put("plato", PlanXMLConstants.PLATO_NS); xpath.setNamespaceURIs(namespaceMap); @SuppressWarnings("unchecked") List<Element> elements = xpath.selectNodes(doc); List<Integer> objectIds = new ArrayList<Integer>(elements.size()); for (Element element : elements) { objectIds.add(Integer.parseInt(element.getStringValue())); } return objectIds; }
From source file:eu.scape_project.planning.xml.ProjectExportAction.java
License:Apache License
/** * Returns the collection profile IDs that are in the document without data. * /*from ww w. j a v a 2 s.c o m*/ * @param doc * the docuemnt to seasrch * @return a list of IDs */ private List<Integer> getPreservationActionPlanIds(Document doc) { // Get data elements that have data and a number as content XPath xpath = doc.createXPath("//plato:preservationActionPlan[number(.) = number(.)]"); Map<String, String> namespaceMap = new HashMap<String, String>(); namespaceMap.put("plato", PlanXMLConstants.PLATO_NS); xpath.setNamespaceURIs(namespaceMap); @SuppressWarnings("unchecked") List<Element> elements = xpath.selectNodes(doc); List<Integer> objectIds = new ArrayList<Integer>(elements.size()); for (Element element : elements) { objectIds.add(Integer.parseInt(element.getStringValue())); } return objectIds; }
From source file:fedora.server.messaging.FedoraTypes.java
License:fedora commons license
public String getDatatype(String method, String param) { String key = method + "." + param; if (!method2datatype.containsKey(key)) { String query = String.format("/xsd:schema/xsd:element[@name='%s']" + "/xsd:complexType/xsd:sequence" + "/xsd:element[@name='%s']/@type", method, param); XPath xpath = DocumentHelper.createXPath(query); xpath.setNamespaceURIs(ns2prefix); String datatype = xpath.valueOf(getDocument()); if (datatype.equals("")) { datatype = null;//w ww.j a v a 2s . c o m } method2datatype.put(key, datatype); } return method2datatype.get(key); }
From source file:fedora.server.messaging.FedoraTypes.java
License:fedora commons license
public String getResponseParameter(String response) { if (!response2parameter.containsKey(response)) { String query = String.format( "/xsd:schema/xsd:element[@name='%s']" + "/xsd:complexType/xsd:sequence" + "/xsd:element/@name", response);//from w w w .j a va 2 s . com XPath xpath = DocumentHelper.createXPath(query); xpath.setNamespaceURIs(ns2prefix); String param = xpath.valueOf(getDocument()); if (param.equals("")) { param = null; } response2parameter.put(response, param); } return response2parameter.get(response); }
From source file:fr.itris.glips.svgeditor.display.canvas.SVGCanvas.java
License:LGPL
/** * add style.svg to doc//from w ww.j a v a2 s . c om * @param doc * @return */ public Document addStyle(Document doc) { //converts the svg document into xml strings StringBuffer buffer = new StringBuffer(""); org.dom4j.Document doc4j = null; for (Node node = doc.getFirstChild(); node != null; node = node.getNextSibling()) { XMLPrinter.writeNode(node, buffer, 0, true, null); } try { doc4j = new SAXReader().read(new ByteArrayInputStream(buffer.toString().getBytes("utf8"))); if (doc4j != null) { XPath x = doc4j.createXPath("/uri:svg/uri:defs"); x.setNamespaceURIs(getNamespace(doc4j)); List<org.dom4j.Element> list = x.selectNodes(doc4j); for (org.dom4j.Element t : list) { if ("defs".equalsIgnoreCase(t.getName())) { org.dom4j.Element style = t.addElement("style"); style.addAttribute("type", "css/text"); style.addText(Editor.getEditor().getSymbolManager().getStyle()); } } } } catch (Exception e) { e.printStackTrace(); } String result = SymbolManager.XML2Str(doc4j); // System.out.println(result.substring(result.indexOf("<svg"))); return SymbolManager.Str2XML(result.substring(result.indexOf("<svg"))); }
From source file:net.sf.jguard.ext.authentication.manager.XmlAuthenticationManager.java
License:Open Source License
private Element getElement(String xpath) { XPath xp2 = DocumentHelper.createXPath(xpath); Map<String, String> uris = new HashMap<String, String>(); uris.put(STRING_NAMESPACE_PREFIX, HTTP_JGUARD_SOURCEFORGE_NET_XSD_J_GUARD_USERS_PRINCIPALS_2_0_0_XSD); xp2.setNamespaceURIs(uris); return (Element) xp2.selectSingleNode(root); }
From source file:net.sf.jguard.ext.authorization.manager.XmlAuthorizationManager.java
License:Open Source License
private Element getElement(String xpath) { XPath xp2 = DocumentHelper.createXPath(xpath); Map<String, String> uris = new HashMap<String, String>(); uris.put(STRING_NAMESPACE_PREFIX, HTTP_JGUARD_SOURCEFORGE_NET_XSD_J_GUARD_PRINCIPALS_PERMISSIONS_2_0_0); xp2.setNamespaceURIs(uris); return (Element) xp2.selectSingleNode(root); }