List of usage examples for org.w3c.dom Element getParentNode
public Node getParentNode();
From source file:net.phoenix.thrift.xml.ArgsBeanDefinitionParser.java
@Override protected void preParse(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) { Element parent = (Element) element.getParentNode(); String name = parent.getAttribute("name") + BEAN_NAME_SUFFIX; if (StringUtils.isEmpty(element.getAttribute("id"))) { element.setAttribute("id", name); }// w w w . ja v a 2 s . com if (StringUtils.isEmpty(element.getAttribute("name"))) { element.setAttribute("name", name); } builder.addConstructorArgValue(this.buildSocket(element)); }
From source file:de.erdesignerng.model.serializer.xml30.XMLAttributeSerializer.java
@Override public void deserialize(Model aModel, ModelItem aTableOrCustomType, Element aElement) { // Parse the Attributes NodeList theAttributes = aElement.getElementsByTagName(ATTRIBUTE); for (int j = 0; j < theAttributes.getLength(); j++) { Element theAttributeElement = (Element) theAttributes.item(j); boolean isCustomType = "CustomType".equalsIgnoreCase(theAttributeElement.getParentNode().getNodeName()); boolean isTable = "Table".equalsIgnoreCase(theAttributeElement.getParentNode().getNodeName()); Attribute theAttribute = null; if (isTable) { theAttribute = new Attribute<Table>(); theAttribute.setOwner(aTableOrCustomType); } else if (isCustomType) { theAttribute = new Attribute<CustomType>(); theAttribute.setOwner(aTableOrCustomType); }//from w w w .ja va 2 s .co m deserializeProperties(theAttributeElement, theAttribute); deserializeCommentElement(theAttributeElement, theAttribute); String theDatatypeName = theAttributeElement.getAttribute(DATATYPE); theAttribute.setDatatype((StringUtils.isEmpty(theDatatypeName) ? null : aModel.getAvailableDataTypes().findByName(theDatatypeName))); theAttribute.setDefaultValue(theAttributeElement.getAttribute(DEFAULTVALUE)); // Bug Fixing 2876916 [ERDesignerNG] Reverse-Eng. PgSQL VARCHAR max-length wrong String theAttributeString = theAttributeElement.getAttribute(SIZE); theAttribute .setSize((StringUtils.isEmpty(theAttributeString) || ("null".equals(theAttributeString))) ? null : Integer.parseInt(theAttributeString)); String theFraction = theAttributeElement.getAttribute(FRACTION); if (!StringUtils.isEmpty(theFraction) && !"null".equals(theFraction)) { theAttribute.setFraction(Integer.parseInt(theFraction)); } theAttribute.setScale(Integer.parseInt(theAttributeElement.getAttribute(SCALE))); theAttribute.setNullable(TRUE.equals(theAttributeElement.getAttribute(NULLABLE))); theAttribute.setExtra(theAttributeElement.getAttribute(EXTRA)); if (isTable) { ((Table) aTableOrCustomType).getAttributes().add(theAttribute); } else if (isCustomType) { ((CustomType) aTableOrCustomType).getAttributes().add(theAttribute); } } }
From source file:com.amalto.core.history.accessor.UnaryFieldAccessor.java
@Override public void delete() { while (exist()) { Element element = getElement(); element.getParentNode().removeChild(element); }//from w ww. j a va 2 s . c o m // if the parent is exist and have no the child, will remove. if (parent.exist() && isEmptyChildForXSIType()) { Node parentNode = parent.getNode(); parentNode.getParentNode().removeChild(parentNode); } }
From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java
/** * Find the first compatible service related element name of the root. * <p>// w ww .j a va 2s. com * Compatible service should be SOAP protocol version 1.1 and 1.2. * </p> * * @param root Root element of wsdl * @param sense Communication sense type * @return First compatible service class name */ public static String findFirstCompatibleServiceElementName(Element root) { Validate.notNull(root, ROOT_ELEMENT_REQUIRED); Element port = findFirstCompatiblePort(root); // Get the path to the service class defined by the wsdl Element service = ((Element) port.getParentNode()); String name = service.getAttribute(NAME_ATTRIBUTE); StringUtils.isNotBlank(name); return name; }
From source file:com.photon.phresco.framework.impl.ConfigurationWriter.java
/** * Delete the environments/* www .ja v a 2 s . c o m*/ * @param selectedEnvs * @throws Exception */ public void deleteEnvironments(List<String> envNames) throws Exception { for (String envName : envNames) { String xpath = getXpathEnv(envName).toString(); Element envNode = (Element) getNode(xpath); envNode.getParentNode().removeChild(envNode); if (!reader.canDelete(envNode)) { throw new Exception(envNode.getAttribute("name") + " can be deleted"); } } }
From source file:org.gvnix.service.roo.addon.addon.util.WsdlParserUtils.java
/** * Is wsdl document root element rpc encoded ? * //from www . j av a 2s .co m * @param root Wsdl document root element * @return is rpc endoded */ public static boolean isRpcEncoded(Element root) { Validate.notNull(root, ROOT_ELEMENT_REQUIRED); // Find binding element Element binding = findFirstCompatibleBinding(root); // Find all child bindings List<Element> childs = XmlUtils.findElements(CHILD_BINDINGS_XPATH, root); Validate.notEmpty(childs, "No valid child bindings format"); // Get child binding related to binding element for (Element child : childs) { // Get child parent binding element name Element parentBinding = ((Element) child.getParentNode()); String name = parentBinding.getAttribute(NAME_ATTRIBUTE); StringUtils.isNotEmpty(name); // If parent binding has the same name as binding if (name.equals(binding.getAttribute(NAME_ATTRIBUTE))) { // Check RPC style String style = child.getAttribute(STYLE_ATTRIBUTE); StringUtils.isNotEmpty(name); if ("rpc".equalsIgnoreCase(style)) { return true; } } /* * TODO To be completed like next condition for each operation: * * (bindingStyle = RPC | operationStyle == RPC) & (inputUse = * ENCODED | outputUse = ENCODED) * * If any operation match previous condition, then is rpc encoded */ } return false; }
From source file:net.phoenix.thrift.xml.ArgsBeanDefinitionParser.java
@Override protected String getBeanClassName(Element argsElement) { String className = argsElement.getAttribute("class"); if (StringUtils.isEmpty(className)) { Element parent = (Element) argsElement.getParentNode(); className = parent.getAttribute("class") + ".Args"; }/*from w ww . ja v a 2 s .c o m*/ LOG.info("Using '" + className + "' for server args classname."); return className; }
From source file:eu.europa.esig.dss.xades.signature.EnvelopedSignatureBuilder.java
/** * Bob --> This method is not used anymore, but it can replace {@code NOT_ANCESTOR_OR_SELF_DS_SIGNATURE} transformation. Performance test should be performed! * In case of the enveloped signature the existing signatures are removed. * * @param domDoc {@code Document} containing the signatures to analyse *///w w w. j a va 2 s . c o m protected void removeExistingSignatures(final Document domDoc) { final NodeList signatureNodeList = domDoc.getElementsByTagNameNS(XMLSignature.XMLNS, XPathQueryHolder.XMLE_SIGNATURE); for (int ii = signatureNodeList.getLength() - 1; ii >= 0; ii--) { final Element signatureDOM = (Element) signatureNodeList.item(ii); signatureDOM.getParentNode().removeChild(signatureDOM); } }
From source file:org.gvnix.web.menu.roo.addon.MenuOperationsImpl.java
public void cleanUpFinderMenuItems(JavaSymbolName menuCategoryName, List<String> allowedFinderMenuIds, LogicalPath logicalPath) {//from w w w.ja va 2 s .c o m waitToReferences(); // TODO Added logicalPath param to method: related methods modification // required ? Validate.notNull(menuCategoryName, "Menu category identifier required"); Validate.notNull(allowedFinderMenuIds, "List of allowed menu items required"); Document document = operations.getMenuDocument(); StringBuilder categoryId = new StringBuilder(MenuEntryOperations.CATEGORY_MENU_ITEM_PREFIX); categoryId.append(menuCategoryName.getSymbolName().toLowerCase()); // find any menu items under this category which have an id that starts // with the menuItemIdPrefix List<Element> elements = XmlUtils.findElements("//menu-item[@id='".concat(categoryId.toString()) .concat("']//menu-item[starts-with(@id, '").concat(FINDER_MENU_ITEM_PREFIX).concat("')]"), document.getDocumentElement()); if (elements.size() == 0) { return; } for (Element element : elements) { if (!allowedFinderMenuIds.contains(element.getAttribute("id"))) { element.getParentNode().removeChild(element); } } xmlFileManager.writeToDiskIfNecessary(operations.getMenuConfigFile(), document); }
From source file:importer.handler.post.stages.Splitter.java
/** * Percolate the versions accumulated in root to suitable sub-elements * @param elem the start node with its versions to percolate *//* ww w .jav a2 s. c o m*/ private void percolateDown(Element elem) { Node parent = elem.getParentNode(); if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) { System.out.println(elem.getNodeName()); String vers = ((Element) parent).getAttribute(VERSIONS); if (vers != null && vers.length() > 0) { if (!discriminator.isSibling(elem)) { Discriminator.addVersion(elem, vers); addDoneTag(elem); } else if (elem.hasAttribute(FINAL)) { String fVers = elem.getAttribute(FINAL); if (fVers != null && fVers.length() > 0) { // find inverse versions HashSet<String> invVers = new HashSet<String>(); String[] parts = vers.split(" "); String[] iparts = fVers.split(" "); for (int i = 0; i < parts.length; i++) if ( /*!parts[i].startsWith(DEL) &&*/ !parts[i].equals(BASE)) invVers.add(parts[i]); for (int i = 0; i < iparts.length; i++) if (invVers.contains(iparts[i])) invVers.remove(iparts[i]); String newVers = hashsetToString(invVers); Discriminator.addVersion(elem, newVers); addDoneTag(elem); Element lastOChild = discriminator.lastOpenChild(elem); while (lastOChild != null) { Discriminator.addVersion(lastOChild, newVers); lastOChild = discriminator.lastOpenChild(lastOChild); } } } // else ignore it } } // now examine the children of elem Element child = Discriminator.firstChild(elem); while (child != null && !isDone(child)) { percolateDown(child); child = Discriminator.firstChild(child); } // finall the siblings of elem Element brother = Discriminator.nextSibling(elem, true); while (brother != null) { if (!isDone(brother)) percolateDown(brother); brother = Discriminator.nextSibling(brother, true); } }