List of usage examples for org.w3c.dom Element getLocalName
public String getLocalName();
From source file:org.cruxframework.crux.core.declarativeui.ViewParser.java
/** * @param cruxPageElement/* www . jav a 2s .c o m*/ * @param htmlElement */ private void translateCruxCoreElements(Element cruxPageElement, Element htmlElement, Document htmlDocument) { String nodeName = cruxPageElement.getLocalName(); if (nodeName.equals(CRUX_CORE_SCREEN)) { translateDocument(cruxPageElement, htmlElement, true); } // else IGNORE }
From source file:org.cruxframework.crux.core.declarativeui.ViewParser.java
/** * @param cruxPageElement/*from w w w. ja va2s. co m*/ * @return */ private String updateCurrentWidgetTag(Element cruxPageElement) { String canditateWidgetType = getLibraryName(cruxPageElement) + "_" + cruxPageElement.getLocalName(); if (StringUtils.isEmpty(cruxTagName)) { cruxTagName = canditateWidgetType; } else { cruxTagName += "_" + cruxPageElement.getLocalName(); } if (!isWidgetSubTag(cruxTagName) && (isWidget(canditateWidgetType))) { cruxTagName = canditateWidgetType; } if (isReferencedWidget(cruxTagName)) { cruxTagName = getReferencedWidget(cruxTagName); } return cruxTagName; }
From source file:org.deegree.framework.xml.XMLFragment.java
/** * Returns the qualified name of the given element. * /* w ww .ja v a 2 s . c o m*/ * @param element * @return the qualified name of the given element. * @throws XMLParsingException */ protected QualifiedName getQualifiedName(Element element) throws XMLParsingException { // TODO check if we can use element.getNamespaceURI() instead URI nsURI = null; String prefix = element.getPrefix(); try { nsURI = XMLTools.getNamespaceForPrefix(prefix, element); } catch (URISyntaxException e) { String msg = Messages.format("ERROR_NSURI_NO_URI", element.getPrefix()); LOG.logError(msg, e); throw new XMLParsingException(msg, e); } QualifiedName ftName = new QualifiedName(prefix, element.getLocalName(), nsURI); return ftName; }
From source file:org.deegree.portal.context.WebMapContextFactory.java
/** * creates an instance of a class encapsulating the GUI description of one region of the GUI * /*from ww w . j a va 2 s. c om*/ * @param element * <West>; <East>; <South>; <North> or <Center> * * @return instance of <tt>GUIArea</tt> * * @throws XMLParsingException * @throws SAXException * @throws IOException */ private static GUIArea createGUIArea(Element element, XMLFragment xml) throws XMLParsingException, IOException, SAXException { GUIArea gui = null; if (element != null) { String tmp = element.getLocalName(); int area = 0; if (tmp.equals("West")) { area = GUIArea.WEST; } else if (tmp.equals("East")) { area = GUIArea.EAST; } else if (tmp.equals("South")) { area = GUIArea.SOUTH; } else if (tmp.equals("North")) { area = GUIArea.NORTH; } else if (tmp.equals("Center")) { area = GUIArea.CENTER; } NamespaceContext nsContext = CommonNamespaces.getNamespaceContext(); int w = XMLTools.getNodeAsInt(element, "./@width", nsContext, -1); int h = XMLTools.getNodeAsInt(element, "./@height", nsContext, -1); int l = XMLTools.getNodeAsInt(element, "./@left", nsContext, -1); int t = XMLTools.getNodeAsInt(element, "./@top", nsContext, -1); int r = XMLTools.getNodeAsInt(element, "./@right", nsContext, -1); int b = XMLTools.getNodeAsInt(element, "./@bottom", nsContext, -1); boolean ov = XMLTools.getNodeAsBoolean(element, "./@overlay", nsContext, false); boolean head = XMLTools.getNodeAsBoolean(element, "./@header", nsContext, false); boolean close = XMLTools.getNodeAsBoolean(element, "./@closable", nsContext, false); // hidden tmp = XMLTools.getAttrValue(element, null, "hidden", null); boolean hidden = "1".equals(tmp) || "true".equals(tmp); // <Module> ElementList el = XMLTools.getChildElements("Module", CommonNamespaces.DGCNTXTNS, element); Module[] modules = new Module[el.getLength()]; for (int i = 0; i < modules.length; i++) { modules[i] = createModule(el.item(i), xml); } gui = new GUIArea(area, hidden, w, h, l, t, r, b, ov, head, close, modules); } return gui; }
From source file:org.deegree.portal.standard.csw.control.SimpleSearchListener.java
/** * Performs the CSW request and returns the result as a HashMap * //ww w . ja v a 2 s . co m * @param protocol * @param request * @param catalogs * @return Returns a <code>HashMap</code>, which contains one key-value-pair for each catalogue, that has been * searched. The key is the name of the catalogue. The value is the doc Document, that contains the number * of matches (resultType="HITS"), or 1 to n metadata entries (resultType="RESULTS") * @throws CatalogClientException */ protected HashMap performRequest(String protocol, String request, List catalogs) throws CatalogClientException { HashMap<String, Document> result = new HashMap<String, Document>(); // loop for all catalogues contained in catalogs for (int i = 0; i < catalogs.size(); i++) { boolean useSOAP = false; List list = config.getCatalogProtocols((String) catalogs.get(i)); LOG.logDebug("Catalog List length=", list.size()); if (protocol != null) { if (!list.contains(protocol)) { throw new CatalogClientException(Messages.getMessage("IGEO_STD_CSW_UNSUPPORTED_PROTOCOL")); } useSOAP = "SOAP".equals(protocol); } else { for (int j = 0; j < list.size(); j++) { if ("SOAP".equals(list.get(j))) { useSOAP = true; break; } } } String cswAddress = config.getCatalogServerAddress((String) catalogs.get(i)); if (cswAddress == null) { throw new CatalogClientException(Messages.getMessage("IGEO_STD_CSW_WRONG_SERVER_ADDR")); } try { if (useSOAP) { // TODO test if this SOAP is working properly StringBuffer soapRequest = new StringBuffer(5000); soapRequest.append("<soap:Envelope "); soapRequest.append("xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\" "); soapRequest.append("soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">"); soapRequest.append(request).append("</soap:Envelope>"); request = soapRequest.toString(); } // send post request HttpClient httpclient = new HttpClient(); LOG.logDebug("CSW Address: " + cswAddress); httpclient = WebUtils.enableProxyUsage(httpclient, new URL(cswAddress)); httpclient.getHttpConnectionManager().getParams().setSoTimeout(30000); PostMethod postMethod = new PostMethod(cswAddress); postMethod.setRequestEntity( new StringRequestEntity(request, "text/xml", CharsetUtils.getSystemCharset())); httpclient.executeMethod(postMethod); // String resp = postMethod.getResponseBodyAsString(); // Document doc = XMLTools.parse( new StringReader( resp ) ); // Using XMLFragment instead of XMLTools to avoid encoding problems XMLFragment frag = new XMLFragment(); frag.load(postMethod.getResponseBodyAsStream(), cswAddress); Document doc = frag.getRootElement().getOwnerDocument(); Element root = doc.getDocumentElement(); if (root.getLocalName().equals("ExceptionReport")) { LOG.logError("CSW Error\n " + new XMLFragment(root).getAsPrettyString()); throw new CatalogClientException(extractException(root)); } else if (LOG.getLevel() == ILogger.LOG_DEBUG) { LOG.logDebug("\nResponse: \n", new XMLFragment(root).getAsPrettyString()); } // write key-value-pair to HashMap result.put((String) catalogs.get(i), doc); } catch (Exception e) { LOG.logError(e.getMessage(), e); throw new CatalogClientException(e.getMessage()); } } return result; }
From source file:org.deegree.portal.standard.csw.control.SimpleSearchListener.java
/** * The number of matches returned is the number of matches for all catalogs added together. * /* w w w .j a v a2 s. co m*/ * @param result * The HashMap containing the result document from the performed request. * @return Returns the number of matches indicated in the result. * @throws XMLParsingException * if the result document in the passed HashMap does not contain the expected nodes and attributes. */ private int numberOfMatchesInMap(HashMap result) throws XMLParsingException { int hits = 0; Iterator iterator = result.keySet().iterator(); while (iterator.hasNext()) { String catalog = (String) iterator.next(); Document doc = (Document) result.get(catalog); // result(value) Element root = doc.getDocumentElement(); if (root.getLocalName().equals("ExceptionReport")) { LOG.logError("csw Error\n " + new XMLFragment(root).getAsPrettyString()); throw new XMLParsingException(extractException(root)); } int matches = numberOfMatchesInDoc(doc); hits += matches; } return hits; }
From source file:org.deegree.portal.standard.csw.control.SimpleSearchListener.java
/** * The number of matches returned is the number for one single catalog. * /* ww w .ja v a2s.c o m*/ * @param doc * The Document containing the result for one catalog. * @return Returns the number of matches for one catalog only. * @throws XMLParsingException */ private int numberOfMatchesInDoc(Document doc) throws XMLParsingException { Element docElement = doc.getDocumentElement(); // root element if (docElement.getLocalName().equals("ExceptionReport")) { LOG.logError("csw Error\n " + new XMLFragment(docElement).getAsPrettyString()); throw new XMLParsingException(extractException(docElement)); } Element searchResults = (Element) XMLTools.getRequiredNode(docElement, StringTools.concat(100, "./", CommonNamespaces.CSW202_PREFIX, ":SearchResults"), nsContext); String matches = XMLTools.getRequiredAttrValue("numberOfRecordsMatched", null, searchResults); return Integer.parseInt(matches); }
From source file:org.dhatim.xml.DomUtils.java
/** * Get the name from the supplied element. * <p/>//from w w w . jav a 2s. c o m * Returns the {@link Node#getLocalName() localName} of the element * if set (namespaced element), otherwise the * element's {@link Element#getTagName() tagName} is returned. * @param element The element. * @return The element name. */ public static String getName(Element element) { AssertArgument.isNotNull(element, "element"); String name = element.getLocalName(); if (name != null) { return name; } else { return element.getTagName(); } }
From source file:org.ebayopensource.turmeric.eclipse.typelibrary.ui.XSDUtils.java
/** * get the first un-empty description from annotations. Return empty string * if there is no un-empty description./*from w ww. j a v a 2 s .com*/ * * @param annotations * @return */ private String getDescriptionFromAnnotations(EList<XSDAnnotation> annotations) { String description = ""; if (annotations == null || annotations.size() == 0) { return description; } for (XSDAnnotation at : annotations) { EList<Element> list = at.getUserInformation(); for (Element e : list) { String nodeName = e.getLocalName(); String content = e.getTextContent(); if (StringUtils.isEmpty(content) == true) { continue; } if (DOCUMENT_NODE_NAME.equalsIgnoreCase(nodeName)) { return content; } } } return description; }
From source file:org.ebayopensource.turmeric.eclipse.typelibrary.ui.XSDUtils.java
private String getDescriptionFromAnnotation(XSDAnnotation annotation) { String description = ""; if (annotation == null) { return description; }// w w w.j a v a 2 s . c o m EList<Element> list = annotation.getUserInformation(); for (Element e : list) { String nodeName = e.getLocalName(); String content = e.getTextContent(); if (StringUtils.isEmpty(content) == true) { continue; } if (DOCUMENT_NODE_NAME.equalsIgnoreCase(nodeName)) { return content; } } return description; }