List of usage examples for org.w3c.dom Element getNamespaceURI
public String getNamespaceURI();
null
if it is unspecified (see ). From source file:ru.codeinside.gws.crypto.cryptopro.CryptoProvider.java
private static Element first(final Node parent, final String uri, final String localName, final String attrUri, final String attr, final String attrValue) { final NodeList nodes = parent.getChildNodes(); final int n = nodes.getLength(); for (int i = 0; i < n; i++) { final Node node = nodes.item(i); if (node instanceof Element) { final Element element = (Element) node; if (localName.equals(element.getLocalName()) && uri.equals(element.getNamespaceURI()) && attrValue.equals(element.getAttributeNS(attrUri, attr))) { return element; }// w w w .j av a2s . c o m } } return null; }
From source file:ru.codeinside.gws3572c.GMPClientSignTest.java
private static Element first(final Node parent, final String uri, final String localName) { final NodeList nodes = parent.getChildNodes(); final int n = nodes.getLength(); for (int i = 0; i < n; i++) { final Node node = nodes.item(i); if (node instanceof Element) { final Element element = (Element) node; if (localName.equals(element.getLocalName()) && (uri == null || uri.equals(element.getNamespaceURI()))) { return element; }/*w w w . j av a 2s. co m*/ } } return null; }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
/** * @param requestElement erquest element * @param tagName tag name// w ww .j av a 2 s . c o m * @return A method written for array input from MATLAB clients. A more generic method to use is getNodeValues(). Column * Arrays and Horizontal Arrays from MATLAB both work, but it must be passed in directly (i.e. EEArray.ee_ids) */ protected Collection<String> getArrayValues(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Collection<String> value = new HashSet<>(); String node; NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes(); // generic clients // iterate over the child nodes for (int i = 0; i < children.getLength(); i++) { // need to go one more level down into the great-grandchildren Node child = children.item(i).getChildNodes().item(0); // new check to see if the request is a Matlab one // Matlab seems to package the xml such that values are found in every odd (ie. 1, 3, 5, 7, etc) // great-grandchild. If at i=0, there is no value, then it IS a Matlab request. if (i == 0 && child == null) break; if (child.getNodeType() == Node.TEXT_NODE) { node = child.getNodeValue(); value.add(node); } } if (!value.isEmpty()) return value; // MATLAB specific // but it appears that MATLAB encodes it so that every odd (ie. 1, 3, 5, 7, etc) great-grandchild holds the // array value value = new HashSet<>(); for (int i = 1; i < children.getLength(); i = i + 2) { // need to go one more level down into the great-grandchildren Node child = children.item(i).getChildNodes().item(0); // Node child = children.item(i).getFirstChild(); if (child.getNodeType() == Node.TEXT_NODE) { node = child.getNodeValue(); value.add(node); } } if (value.isEmpty()) { throw new IllegalArgumentException("Could not find request text node"); } return value; }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
/** * basically Delegates to getSingleNodeValue and returns the just the last value. * * @param requestElement request element * @param tagName tag name/* w ww . j a v a2s. c o m*/ * @return last value */ protected String getLastSingleNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); String lastValue = null; String node; // get the Element with name = tagName NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes(); // iterate over the child nodes for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.TEXT_NODE) { node = children.item(i).getNodeValue(); lastValue = node; } } if (lastValue == null || lastValue.isEmpty()) { // throw new IllegalArgumentException( "Could not find request text node" ); } return lastValue; }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
protected String getNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Node node = requestElement.getElementsByTagName(tagName).item(0); return node.getNodeValue(); }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
protected String getOptionalNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Node node = requestElement.getElementsByTagName(tagName).item(0); if (node == null) return null; return node.getNodeValue(); }
From source file:ubic.gemma.web.services.AbstractGemmaEndpoint.java
/** * Function that handles the retrieval of xml input. Use this method if there is only one value in the input but * generically, this method can also store multiple input values as well. This will depend on how the xml is parsed * by the client. OLDTODO Still need to test on different types of client requests. * * @param requestElement - xml request in node hierarchy * @param tagName tag name//from w w w . ja v a 2s .c om * @return a collection contain one string element */ /* * OLDTODO return value should be single string object. Note that many services will be affected should we make this * change. */ protected Collection<String> getSingleNodeValue(Element requestElement, String tagName) { Assert.isTrue(AbstractGemmaEndpoint.NAMESPACE_URI.equals(requestElement.getNamespaceURI()), "Invalid namespace"); Assert.isTrue(localName.equals(requestElement.getLocalName()), "Invalid local name"); this.authenticate(); Collection<String> value = new HashSet<>(); String node; // get the Element with name = tagName NodeList children = requestElement.getElementsByTagName(tagName).item(0).getChildNodes(); // iterate over the child nodes for (int i = 0; i < children.getLength(); i++) { if (children.item(i).getNodeType() == Node.TEXT_NODE) { node = children.item(i).getNodeValue(); value.add(node); } } if (value.isEmpty()) { // throw new IllegalArgumentException( "Could not find request text node" ); } return value; }