List of usage examples for org.w3c.dom Node getLocalName
public String getLocalName();
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java
@Test public void dialogsAreValid() throws XPathExpressionException { //Get all dialogs NodeList dialogs = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:Dialog", doc, XPathConstants.NODESET); for (int i = 0; i < dialogs.getLength(); i++) { NodeList dialogChildren = dialogs.item(i).getChildNodes(); int numTitles = 0; int numLabels = 0; int numDialog = 0; int numHintWidth = 0; int numHintHeight = 0; //Check children of dialog for (int j = 0; j < dialogChildren.getLength(); j++) { Node dChild = dialogChildren.item(j); if (dChild.getLocalName() == null) { continue; }/*from w ww . ja v a 2 s . com*/ if (dChild.getLocalName().equals("title") && dChild.getNamespaceURI().equals(OSLCConstants.DC)) { numTitles++; } if (dChild.getLocalName().equals("dialog") && dChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numDialog++; } if (dChild.getLocalName().equals("label") && dChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numLabels++; } if (dChild.getLocalName().equals("hintWidth") && dChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numHintWidth++; } if (dChild.getLocalName().equals("hintHeight") && dChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numHintHeight++; } } //Make sure we have a title, a dialog child element, at most one label/hintWidth/hintHeight assertTrue(numTitles == 1); assertTrue(numDialog == 1); assertTrue(numLabels <= 1); assertTrue(numHintWidth <= 1); assertTrue(numHintHeight <= 1); } }
From source file:com.apatar.buzzsaw.BuzzsawNode.java
private void putPropertyValueToTable(Node node, KeyInsensitiveMap datas) { String fieldNameSpace = node.getNamespaceURI(); String fieldName = node.getLocalName(); String fieldValue = node.getTextContent(); // does node have children or not if (node.hasChildNodes()) { for (int i = 0; i < node.getChildNodes().getLength(); i++) { if (1 == node.getChildNodes().item(i).getNodeType()) { putPropertyValueToTable(node.getChildNodes().item(i), datas); }/* w w w.j a va 2 s. c o m*/ } } // is this bazzsaw property or not if ("http://www.buzzsaw.com/projectpoint".equalsIgnoreCase(fieldNameSpace)) { fieldName = "Buzzsaw_" + fieldName; } List<Record> recs = getTiForConnection(OUT_CONN_POINT_NAME).getRecords(); Record rec = Record.getRecordByFieldName(recs, fieldName); if (rec != null) { datas.put(fieldName, new JdbcObject(fieldValue, rec.getSqlType())); } }
From source file:de.fau.cs.osr.hddiff.perfsuite.RunXyDiff.java
private void evaluateDiff(Node node, int depth, boolean parentIsTextContainer, GenericEditOp op) { String indent = null;/*w ww . j av a2 s.c o m*/ Edit e = null; GenericEditOp childOp = op; boolean isTextContainer = false; boolean descend = true; String localName = node.getLocalName(); if (localName == null) { e = handleXmlText(node, op, parentIsTextContainer, indent); } else { String namespaceURI = node.getNamespaceURI(); if (Wom3Node.WOM_NS_URI.equals(namespaceURI) || AstToWomConverter.MWW_NS_URI.equals(namespaceURI)) { if ((op == null) || (op == GenericEditOp.NONE)) xyDiffConfusesMe(); e = new Edit(op, localName, null); isTextContainer = ("text".equals(localName) || "rtd".equals(localName)); } else if ("urn:schemas-xydiff:xydelta".equals(namespaceURI)) { if (op != null && op != GenericEditOp.NONE) xyDiffConfusesMe(); if ("unit_delta".equals(localName) || "t".equals(localName)) { // Don't know what that means... } else if ("d".equals(localName)) { Node namedItem = node.getAttributes().getNamedItem("move"); if (namedItem != null && "yes".equalsIgnoreCase(namedItem.getNodeValue())) { // We only count moves on insert, not delete } else { childOp = GenericEditOp.DEL; } } else if ("i".equals(localName)) { Node namedItem = node.getAttributes().getNamedItem("move"); if (namedItem != null && "yes".equalsIgnoreCase(namedItem.getNodeValue())) { childOp = GenericEditOp.MOV; e = new Edit(GenericEditOp.MOV, "#move", null); } else { childOp = GenericEditOp.INS; } } else if ("au".equals(localName) || "ai".equals(localName) || "ad".equals(localName)) { // We ignore attribute update/insert/delete } else if ("u".equals(localName)) { e = evaluateUpdate(node); descend = false; } else { xyDiffConfusesMe(); } } else { xyDiffConfusesMe(); } } // Insert/move/update top-down if ((e != null) && (e.op != GenericEditOp.DEL)) editScriptAnalysis.add(e); if (descend) { NodeList children = node.getChildNodes(); int len = children.getLength(); for (int i = 0; i < len; ++i) { Node child = children.item(i); evaluateDiff(child, depth + 1, isTextContainer, childOp); } } // Delete bottom-up if ((e != null) && (e.op == GenericEditOp.DEL)) editScriptAnalysis.add(e); }
From source file:edu.internet2.middleware.shibboleth.common.config.BaseSpringNamespaceHandler.java
/** * Locates the {@link BeanDefinitionParser} from the register implementations using the local name of the supplied * {@link org.w3c.dom.Node}. Supports both {@link org.w3c.dom.Element Elements} and {@link org.w3c.dom.Attr Attrs}. * //from ww w . j av a 2 s. com * @param node the node to locate the decorator for * * @return the decorator for the given node */ protected BeanDefinitionDecorator findDecoratorForNode(Node node) { BeanDefinitionDecorator decorator = null; if (node instanceof Element) { decorator = decorators.get(XMLHelper.getXSIType((Element) node)); if (decorator == null) { decorator = decorators.get(XMLHelper.getNodeQName(node)); } } else if (node instanceof Attr) { decorator = attributeDecorators.get(node.getLocalName()); } else { throw new IllegalArgumentException( "Cannot decorate based on Nodes of type [" + node.getClass().getName() + "]"); } if (decorator == null) { throw new IllegalArgumentException( "Cannot locate BeanDefinitionDecorator for " + " [" + node.getLocalName() + "]"); } return decorator; }
From source file:de.fau.cs.osr.hddiff.perfsuite.RunFcDiff.java
private boolean cmpTag(Node node, String ns, String tag) { if (node.getNodeType() != Node.ELEMENT_NODE) return false; String localName = node.getLocalName(); if (localName == null) localName = node.getNodeName();// ww w .j a v a 2 s . com return cmpStr(node.getNamespaceURI(), ns) && cmpStr(localName, tag); }
From source file:Main.java
/** * Checks if two Nodes are equal<br> * <p/>//from w ww . j a v a2 s . c o m * Compares Nodes just by their Name, Type, Value and Namespace generically */ public static boolean nodesEqual(Node node1, Node node2, boolean ignoreWhitespace) { if ((node1 == null) || (node2 == null)) return false; /* if (node1.getNodeType() == node2.getNodeType() && (areNullorEqual(node1.getNodeValue(), node2.getNodeValue(), ignoreWhitespace, false)) && (areNullorEqual(node1.getLocalName(), node2.getLocalName(), ignoreWhitespace, false)) && (areNullorEqual(node1.getNamespaceURI(), node2.getNamespaceURI(), ignoreWhitespace, false)) && (areNullorEqual(node1.getNodeName(), node2.getNodeName(), ignoreWhitespace, false))) return true; */ if (areNonNullAndEqual(node1.getNamespaceURI(), node2.getNamespaceURI())) { if (node1.getNodeType() == node2.getNodeType() && (areNullorEqual(node1.getNodeValue(), node2.getNodeValue(), ignoreWhitespace, false)) && (areNullorEqual(node1.getLocalName(), node2.getLocalName(), ignoreWhitespace, false))) return true; } else if ((node1.getNamespaceURI() == null) && (node2.getNamespaceURI() == null)) { //System.out.println("===> Both Namespace URIs are null"); if ((node1.getNodeType() == node2.getNodeType()) && (areNullorEqual(node1.getNodeValue(), node2.getNodeValue(), ignoreWhitespace, false)) && (areNullorEqual(node1.getNodeName(), node2.getNodeName(), ignoreWhitespace, false))) return true; } return false; }
From source file:com.eviware.soapui.impl.wsdl.submit.transports.http.support.attachments.WsdlMimeMessageResponse.java
private void expandMtomAttachments(WsdlRequest wsdlRequest) { try {//from w w w .j av a2 s.co m // XmlObject xmlObject = XmlObject.Factory.parse( getContentAsString() // ); XmlObject xmlObject = XmlUtils.createXmlObject(getContentAsString()); XmlObject[] includes = xmlObject .selectPath("declare namespace xop='http://www.w3.org/2004/08/xop/include'; //xop:Include"); for (XmlObject include : includes) { Element elm = (Element) include.getDomNode(); String href = elm.getAttribute("href"); Attachment attachment = getMmSupport().getAttachmentWithContentId("<" + href.substring(4) + ">"); if (attachment != null) { ByteArrayOutputStream data = Tools.readAll(attachment.getInputStream(), 0); byte[] byteArray = data.toByteArray(); XmlCursor cursor = include.newCursor(); cursor.toParent(); XmlObject parentXmlObject = cursor.getObject(); cursor.dispose(); SchemaType schemaType = parentXmlObject.schemaType(); Node parentNode = elm.getParentNode(); if (schemaType.isNoType()) { SchemaTypeSystem typeSystem = wsdlRequest.getOperation().getInterface().getWsdlContext() .getSchemaTypeSystem(); SchemaGlobalElement schemaElement = typeSystem .findElement(new QName(parentNode.getNamespaceURI(), parentNode.getLocalName())); if (schemaElement != null) { schemaType = schemaElement.getType(); } } String txt = null; if (SchemaUtils.isInstanceOf(schemaType, XmlHexBinary.type)) { txt = new String(Hex.encodeHex(byteArray)); } else { txt = new String(Base64.encodeBase64(byteArray)); } parentNode.replaceChild(elm.getOwnerDocument().createTextNode(txt), elm); } } getMmSupport().setResponseContent(xmlObject.toString()); } catch (Exception e) { SoapUI.logError(e); } }
From source file:com.vmware.identity.sts.ws.SignatureValidator.java
/** * @param parentNode//from w ww .j a v a 2s .co m * not null * @param elementName name of the element to find * @return the XML node */ private Node getChildNode(Node parentNode, String elementName) { assert parentNode != null; NodeList childNodes = parentNode.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node nextNode = childNodes.item(i); final String nextNodeName = nextNode.getLocalName(); if (nextNodeName != null && nextNodeName.equals(elementName)) { return nextNode; } } throw new WSFaultException(FaultKey.WSSE_INVALID_SECURITY, String.format("XML node '%s' cannot be found", elementName)); }
From source file:de.betterform.xml.xforms.ui.Switch.java
/** * Initializes the Case elements.//from w w w .j a v a 2s .co m * <p/> * If multiple Cases within a Switch are selected, the first selected Case * remains and all others are deselected. If none are selected, the first * becomes selected. */ protected final void initializeSwitch() throws XFormsException { NodeList childNodes = getElement().getChildNodes(); List cases = new ArrayList(childNodes.getLength()); Node node; Case caseElement; String selectedAttribute; int selection = -1; for (int index = 0; index < childNodes.getLength(); index++) { node = childNodes.item(index); if (node.getNodeType() == Node.ELEMENT_NODE && NamespaceConstants.XFORMS_NS.equals(node.getNamespaceURI()) && CASE.equals(node.getLocalName())) { caseElement = (Case) ((Node) node).getUserData(""); cases.add(caseElement); selectedAttribute = caseElement.getXFormsAttribute(SELECTED_ATTRIBUTE); if ((selection == -1) && ("true").equals(selectedAttribute)) { // keep *first* selected case position selection = cases.size() - 1; } } } if (selection == -1) { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: choosing first case for selection by default"); } // select first case if none is selected selection = 0; } // perform selection/deselection for (int index = 0; index < cases.size(); index++) { caseElement = (Case) cases.get(index); if (index == selection) { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: selecting case '" + caseElement.getId() + "'"); } caseElement.select(); } else { if (getLogger().isDebugEnabled()) { getLogger().debug(this + " init: deselecting case '" + caseElement.getId() + "'"); } caseElement.deselect(); } } // set state for updateSwitch() this.initAfterReady = this.model.isReady(); }