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 eachServiceHasOneDomain() throws XPathExpressionException { //Get the services referenced NodeList services = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:service/oslc_v2:Service", doc, XPathConstants.NODESET); for (int i = 0; i < services.getLength(); i++) { NodeList serviceChildren = services.item(i).getChildNodes(); int numDomains = 0; //Check the service for domain child elements for (int j = 0; j < serviceChildren.getLength(); j++) { Node sChild = serviceChildren.item(j); if (sChild.getLocalName() == null) { continue; }/* w w w . j a v a 2s. co m*/ if (sChild.getLocalName().equals("domain") && sChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numDomains++; } } //Make sure the service has exactly one domain element assertTrue(numDomains == 1); } }
From source file:com.centeractive.ws.builder.soap.XmlUtils.java
private static int findNodeIndex(Node node) { String nm = node.getLocalName(); String ns = node.getNamespaceURI(); short nt = node.getNodeType(); Node parentNode = node.getParentNode(); if (parentNode.getNodeType() != Node.ELEMENT_NODE) return 1; Node child = parentNode.getFirstChild(); int ix = 0;//from w ww. java 2s. com while (child != null) { if (child == node) return ix + 1; if (child.getNodeType() == nt && nm.equals(child.getLocalName()) && ((ns == null && child.getNamespaceURI() == null) || (ns != null && ns.equals(child.getNamespaceURI())))) ix++; child = child.getNextSibling(); } throw new SoapBuilderException("Child node not found in parent!?"); }
From source file:com.apatar.buzzsaw.BuzzsawNode.java
private void addDinamicFieldToList(Node node) { String fieldNameSpace = node.getNamespaceURI(); String fieldName = node.getLocalName(); // 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()) { addDinamicFieldToList(node.getChildNodes().item(i)); }//from w ww .ja v a2 s . c om } } // is this bazzsaw property or not if ("http://www.buzzsaw.com/projectpoint".equalsIgnoreCase(fieldNameSpace)) { fieldName = "Buzzsaw_" + fieldName; } // does dinamicFields have fieldName or not if (!dinamicFields.contains(fieldName)) { dinamicFields.add(fieldName); } }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderCatalogXmlTests.java
@Test public void oAuthElementsAreValid() throws XPathExpressionException { // Get all oauthAuthorization xml blocks NodeList oAuthElement = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:oauthConfiguration/*", doc, XPathConstants.NODESET); // Verify the block contains the required expected elements for (int i = 0; i < oAuthElement.getLength(); i++) { NodeList oAuthChildren = oAuthElement.item(i).getChildNodes(); int reqTokenCount = 0; int authCount = 0; int accessCount = 0; for (int j = 0; j < oAuthChildren.getLength(); j++) { Node oAuthNode = oAuthChildren.item(j); if (oAuthNode.getLocalName() == null) { continue; }//from w ww . j a v a 2s. com if (oAuthNode.getLocalName().equals("oauthRequestTokenURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { reqTokenCount++; } if (oAuthNode.getLocalName().equals("authorizationURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { authCount++; } if (oAuthNode.getLocalName().equals("oauthAccessTokenURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { accessCount++; } } assertTrue(reqTokenCount == 1); assertTrue(authCount == 1); assertTrue(accessCount == 1); } }
From source file:com.espertech.esper.client.ConfigurationParser.java
private static String getRequiredAttribute(Node node, String key) { Node valueNode = node.getAttributes().getNamedItem(key); if (valueNode == null) { String name = node.getLocalName(); if (name == null) { name = node.getNodeName();//from w ww .j a v a 2 s .c o m } throw new ConfigurationException( "Required attribute by name '" + key + "' not found for element '" + name + "'"); } return valueNode.getTextContent(); }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderCatalogXmlTests.java
@Test public void publisherElementsAreValid() throws XPathExpressionException { // Get all Publisher xml blocks NodeList publishers = (NodeList) OSLCUtils.getXPath().evaluate("//dc:publisher/*", doc, XPathConstants.NODESET); // Verify that each block contains a title and identifier, and at most // one icon and label for (int i = 0; i < publishers.getLength(); i++) { NodeList publisherElements = publishers.item(i).getChildNodes(); int titleCount = 0; int identifierCount = 0; int iconCount = 0; int labelCount = 0; for (int j = 0; j < publisherElements.getLength(); j++) { Node ele = publisherElements.item(j); if (ele.getLocalName() == null) { continue; }//w ww. j av a 2s . co m if (ele.getNamespaceURI().equals(OSLCConstants.DC) && ele.getLocalName().equals("title")) { titleCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.DC) && ele.getLocalName().equals("identifier")) { identifierCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.OSLC_V2) && ele.getLocalName().equals("label")) { labelCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.OSLC_V2) && ele.getLocalName().equals("icon")) { iconCount++; } } assertTrue(titleCount == 1); assertTrue(identifierCount == 1); assertTrue(iconCount <= 1); assertTrue(labelCount <= 1); } }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java
@Test public void creationFactoriesAreValid() throws XPathExpressionException { //Get all creation factories NodeList factories = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:CreationFactory", doc, XPathConstants.NODESET); for (int i = 0; i < factories.getLength(); i++) { NodeList factoryChildren = factories.item(i).getChildNodes(); int numTitles = 0; int numLabels = 0; int numCreation = 0; //Check children of current creation factory for (int j = 0; j < factoryChildren.getLength(); j++) { Node fChild = factoryChildren.item(j); if (fChild.getLocalName() == null) { continue; }//from w w w . jav a 2 s . c om if (fChild.getLocalName().equals("title") && fChild.getNamespaceURI().equals(OSLCConstants.DC)) { numTitles++; } if (fChild.getLocalName().equals("creation") && fChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numCreation++; } if (fChild.getLocalName().equals("label") && fChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numLabels++; } } //Make sure the factory has a title, a creation element, and at most 1 label assertTrue(numTitles == 1); assertTrue(numCreation == 1); assertTrue(numLabels <= 1); } }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java
@Test public void publisherElementsAreValid() throws XPathExpressionException { //Get all Publisher xml blocks NodeList publishers = (NodeList) OSLCUtils.getXPath().evaluate("//dc:publisher/*", doc, XPathConstants.NODESET); //Verify that each block contains a title and identifier, and at most one icon and label for (int i = 0; i < publishers.getLength(); i++) { NodeList publisherElements = publishers.item(i).getChildNodes(); int titleCount = 0; int identifierCount = 0; int iconCount = 0; int labelCount = 0; for (int j = 0; j < publisherElements.getLength(); j++) { Node ele = publisherElements.item(j); if (ele.getLocalName() == null) { continue; }//from w w w .ja v a 2s.c o m if (ele.getNamespaceURI().equals(OSLCConstants.DC) && ele.getLocalName().equals("title")) { titleCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.DC) && ele.getLocalName().equals("identifier")) { identifierCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.OSLC_V2) && ele.getLocalName().equals("label")) { labelCount++; } if (ele.getNamespaceURI().equals(OSLCConstants.OSLC_V2) && ele.getLocalName().equals("icon")) { iconCount++; } } assertTrue(titleCount == 1); assertTrue(identifierCount == 1); assertTrue(iconCount <= 1); assertTrue(labelCount <= 1); } }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java
@Test public void oAuthElementsAreValid() throws XPathExpressionException { //Get all oauthAuthorization xml blocks NodeList oAuthElement = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:oauthConfiguration/*", doc, XPathConstants.NODESET); //Verify the block contains the required expected elements for (int i = 0; i < oAuthElement.getLength(); i++) { NodeList oAuthChildren = oAuthElement.item(i).getChildNodes(); int reqTokenCount = 0; int authCount = 0; int accessCount = 0; for (int j = 0; j < oAuthChildren.getLength(); j++) { Node oAuthNode = oAuthChildren.item(j); if (oAuthNode.getLocalName() == null) { continue; }/* www . j av a 2 s .c o m*/ if (oAuthNode.getLocalName().equals("oauthRequestTokenURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { reqTokenCount++; } if (oAuthNode.getLocalName().equals("authorizationURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { authCount++; } if (oAuthNode.getLocalName().equals("oauthAccessTokenURI") && oAuthNode.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { accessCount++; } } assertTrue(reqTokenCount == 1); assertTrue(authCount == 1); assertTrue(accessCount == 1); } }
From source file:org.eclipse.lyo.testsuite.oslcv2.ServiceProviderXmlTests.java
@Test public void queryCapabilityBlocksAreValid() throws XPathExpressionException { //Get all query blocks NodeList queryBlocks = (NodeList) OSLCUtils.getXPath().evaluate("//oslc_v2:QueryCapability", doc, XPathConstants.NODESET); for (int i = 0; i < queryBlocks.getLength(); i++) { NodeList queryChildren = queryBlocks.item(i).getChildNodes(); int numTitles = 0; int numLabels = 0; int numQueryBase = 0; int numResourceShape = 0; //Check children of each block for (int j = 0; j < queryChildren.getLength(); j++) { Node qChild = queryChildren.item(j); if (qChild.getLocalName() == null) { continue; }//from w w w .j a v a 2 s . com if (qChild.getLocalName().equals("title") && qChild.getNamespaceURI().equals(OSLCConstants.DC)) { numTitles++; } if (qChild.getLocalName().equals("queryBase") && qChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numQueryBase++; } if (qChild.getLocalName().equals("label") && qChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numLabels++; } if (qChild.getLocalName().equals("resourceShape") && qChild.getNamespaceURI().equals(OSLCConstants.OSLC_V2)) { numResourceShape++; } } //Make sure we have a title, a queryBase, and at most one label/resourceShape assertTrue(numTitles == 1); assertTrue(numQueryBase == 1); assertTrue(numLabels <= 1); assertTrue(numResourceShape <= 1); } }