List of usage examples for org.w3c.dom Node getParentNode
public Node getParentNode();
From source file:org.kie.server.services.jbpm.ui.form.RemoteFormModellerFormProvider.java
protected String filterXML(String document, String lang, String deploymentId, Map inputs, Map outputs) { try {//from w ww.j av a 2 s . co m if (inputs == null) { inputs = Collections.emptyMap(); } if (outputs == null) { outputs = Collections.emptyMap(); } DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(new ByteArrayInputStream(document.getBytes())); NodeList nodes = doc.getElementsByTagName(NODE_FORM); Node nodeForm = nodes.item(0); NodeList childNodes = nodeForm.getChildNodes(); for (int i = 0; i < childNodes.getLength(); i++) { Node node = childNodes.item(i); if (node.getNodeName().equals(NODE_FIELD)) { String fieldType = node.getAttributes().getNamedItem(ATTR_TYPE).getNodeValue(); if (SUB_FORM_TYPE.equals(fieldType)) { String defaultSubForm = findPropertyValue(node, "defaultSubform"); if (defaultSubForm != null) { String subFormContent = formManagerService.getFormByKey(deploymentId, defaultSubForm); if (subFormContent != null) { // read once to find out input binding name Document tmpSubForm = builder .parse(new ByteArrayInputStream(subFormContent.getBytes())); Node firstFieldNode = tmpSubForm.getElementsByTagName(NODE_FIELD).item(0); // inputs - current node String currentNodeInputBinding = findPropertyValue(node, "inputBinding"); currentNodeInputBinding = currentNodeInputBinding.replaceAll("/", "."); // outputs current node String currentNodeOutputBinding = findPropertyValue(node, "outputBinding"); currentNodeOutputBinding = currentNodeOutputBinding.replaceAll("/", "."); // inputs sub form String inputBindingSubForm = findPropertyValue(firstFieldNode, "inputBinding"); inputBindingSubForm = inputBindingSubForm.split("/")[0]; // outputs sub form String outputBindingSubForm = findPropertyValue(firstFieldNode, "outputBinding"); outputBindingSubForm = outputBindingSubForm.split("/")[0]; Map<String, Object> subFormInputs = new HashMap<String, Object>(inputs); try { subFormInputs.put(inputBindingSubForm, MVELSafeHelper.getEvaluator().eval(currentNodeInputBinding, inputs)); } catch (Exception e) { } Map<String, Object> subFormOutputs = new HashMap<String, Object>(outputs); try { subFormOutputs.put(outputBindingSubForm, MVELSafeHelper.getEvaluator().eval(currentNodeOutputBinding, outputs)); } catch (Exception e) { } // run the transformation String filtered = filterXML(subFormContent, lang, deploymentId, subFormInputs, subFormOutputs); Document docSubForm = builder.parse(new ByteArrayInputStream(filtered.getBytes())); NodeList nodesSubForm = docSubForm.getElementsByTagName(NODE_FORM); Node nodeFormSubForm = nodesSubForm.item(0); Node imported = doc.importNode(nodeFormSubForm, true); node.getParentNode().appendChild(imported); } } } else if (MULTI_SUB_FORM_TYPE.equals(fieldType)) { String defaultSubForm = findPropertyValue(node, "defaultSubform"); if (defaultSubForm != null) { String subFormContent = formManagerService.getFormByKey(deploymentId, defaultSubForm); if (subFormContent != null) { String inputBinding = findPropertyValue(node, "inputBinding"); inputBinding = inputBinding.replaceAll("/", "."); String outputBinding = findPropertyValue(node, "outputBinding"); outputBinding = outputBinding.replaceAll("/", "."); Collection<Object> list = new ArrayList<Object>(); Collection<Object> listOut = new ArrayList<Object>(); Map<String, Object> subFormInputs = new HashMap<String, Object>(inputs); Map<String, Object> subFormOutputs = new HashMap<String, Object>(outputs); try { list = (Collection<Object>) MVELSafeHelper.getEvaluator().eval(inputBinding, inputs); } catch (Exception e) { // no elements found add simple object to generate single line list.add(new Object()); } try { listOut = (Collection<Object>) MVELSafeHelper.getEvaluator().eval(outputBinding, outputs); } catch (Exception e) { // no elements found add simple object to generate single line list.add(new Object()); } // read once to find out input binding name Document tmpSubForm = builder .parse(new ByteArrayInputStream(subFormContent.getBytes())); Node firstFieldNode = tmpSubForm.getElementsByTagName(NODE_FIELD).item(0); String inputBindingSubForm = findPropertyValue(firstFieldNode, "inputBinding"); inputBindingSubForm = inputBindingSubForm.split("/")[0]; String outputBindingSubForm = findPropertyValue(firstFieldNode, "outputBinding"); outputBindingSubForm = outputBindingSubForm.split("/")[0]; Node nodeFormSubForm = null; // inputs for (Object element : list) { subFormInputs.put(inputBindingSubForm, element); String filtered = filterXML(subFormContent, lang, deploymentId, subFormInputs, subFormOutputs); Document docSubForm = builder .parse(new ByteArrayInputStream(filtered.getBytes())); NodeList nodesSubForm = docSubForm.getElementsByTagName(NODE_FORM); nodeFormSubForm = nodesSubForm.item(0); } // outputs for (Object element : listOut) { subFormOutputs.put(outputBindingSubForm, element); String filtered = filterXML(subFormContent, lang, deploymentId, Collections.emptyMap(), subFormOutputs); Document docSubForm = builder .parse(new ByteArrayInputStream(filtered.getBytes())); NodeList nodesSubForm = docSubForm.getElementsByTagName(NODE_FORM); nodeFormSubForm = nodesSubForm.item(0); } // Adding nestedForm after filtering inputs & outputs Node imported = doc.importNode(nodeFormSubForm, true); node.getParentNode().appendChild(imported); } } } NodeList fieldPropsNodes = node.getChildNodes(); for (int j = 0; j < fieldPropsNodes.getLength(); j++) { Node nodeFieldProp = fieldPropsNodes.item(j); if (nodeFieldProp.getNodeName().equals(NODE_PROPERTY)) { String propName = nodeFieldProp.getAttributes().getNamedItem(ATTR_NAME).getNodeValue(); String value = StringEscapeUtils.unescapeXml( nodeFieldProp.getAttributes().getNamedItem(ATTR_VALUE).getNodeValue()); if (inputs != null && propName != null && value != null && "inputBinding".equals(propName)) { setPropertyNodeValue(nodeFieldProp, value, inputs); } else if (outputs != null && propName != null && value != null && "outputBinding".equals(propName)) { setPropertyNodeValue(nodeFieldProp, value, outputs); } else if (propName != null && ATTR_LANG_NAMES.contains(propName) && !StringUtils.isEmpty(value)) { filterProperty(nodeFieldProp, lang, value); } } } } } document = asString(doc); } catch (Exception ex) { logger.error("Error when filtering form", ex); } return document; }
From source file:org.kie.workbench.common.stunner.svg.gen.translator.css.SVGStyleTranslator.java
static List<Element> getElementsTree(final Element element) { final List<Element> tree = new LinkedList<>(); tree.add(element);/*from w ww. j a v a 2 s . c o m*/ Node parent = element.getParentNode(); while (null != parent) { if (parent instanceof Element) { tree.add((Element) parent); } parent = parent.getParentNode(); } return tree; }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.PropDevPropDevBudgetSubAwardServiceImpl.java
/** * updates the XMl with hashcode for the files *///from w w w.j a va 2 s . co m protected BudgetSubAwards updateXML(byte xmlContents[], Map fileMap, BudgetSubAwards budgetSubAwardBean, Budget budget) throws Exception { javax.xml.parsers.DocumentBuilderFactory domParserFactory = javax.xml.parsers.DocumentBuilderFactory .newInstance(); javax.xml.parsers.DocumentBuilder domParser = domParserFactory.newDocumentBuilder(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlContents); org.w3c.dom.Document document = domParser.parse(byteArrayInputStream); byteArrayInputStream.close(); String namespace = null; String formName = null; if (document != null) { Node node; Element element = document.getDocumentElement(); NamedNodeMap map = element.getAttributes(); String namespaceHolder = element.getNodeName().substring(0, element.getNodeName().indexOf(':')); node = map.getNamedItem("xmlns:" + namespaceHolder); namespace = node.getNodeValue(); FormMappingInfo formMappingInfo = formMappingService.getFormInfo(namespace); formName = formMappingInfo.getFormName(); budgetSubAwardBean.setNamespace(namespace); budgetSubAwardBean.setFormName(formName); } String xpathEmptyNodes = "//*[not(node()) and local-name(.) != 'FileLocation' and local-name(.) != 'HashValue']"; String xpathOtherPers = "//*[local-name(.)='ProjectRole' and local-name(../../.)='OtherPersonnel' and count(../NumberOfPersonnel)=0]"; removeAllEmptyNodes(document, xpathEmptyNodes, 0); removeAllEmptyNodes(document, xpathOtherPers, 1); removeAllEmptyNodes(document, xpathEmptyNodes, 0); changeDataTypeForNumberOfOtherPersons(document); List<String> fedNonFedSubAwardForms = getFedNonFedSubawardForms(); NodeList budgetYearList = XPathAPI.selectNodeList(document, "//*[local-name(.) = 'BudgetYear']"); for (int i = 0; i < budgetYearList.getLength(); i++) { Node bgtYearNode = budgetYearList.item(i); String period = getValue(XPathAPI.selectSingleNode(bgtYearNode, "BudgetPeriod")); if (fedNonFedSubAwardForms.contains(namespace)) { Element newBudgetYearElement = copyElementToName((Element) bgtYearNode, bgtYearNode.getNodeName()); bgtYearNode.getParentNode().replaceChild(newBudgetYearElement, bgtYearNode); } else { Element newBudgetYearElement = copyElementToName((Element) bgtYearNode, bgtYearNode.getNodeName() + period); bgtYearNode.getParentNode().replaceChild(newBudgetYearElement, bgtYearNode); } } Node oldroot = document.removeChild(document.getDocumentElement()); Node newroot = document.appendChild(document.createElement("Forms")); newroot.appendChild(oldroot); org.w3c.dom.NodeList lstFileName = document.getElementsByTagName("att:FileName"); org.w3c.dom.NodeList lstFileLocation = document.getElementsByTagName("att:FileLocation"); org.w3c.dom.NodeList lstMimeType = document.getElementsByTagName("att:MimeType"); org.w3c.dom.NodeList lstHashValue = document.getElementsByTagName("glob:HashValue"); org.w3c.dom.Node fileNode, hashNode, mimeTypeNode; org.w3c.dom.NamedNodeMap fileNodeMap, hashNodeMap; String fileName; byte fileBytes[]; String contentId; List attachmentList = new ArrayList(); for (int index = 0; index < lstFileName.getLength(); index++) { fileNode = lstFileName.item(index); Node fileNameNode = fileNode.getFirstChild(); fileName = fileNameNode.getNodeValue(); fileBytes = (byte[]) fileMap.get(fileName); if (fileBytes == null) { throw new RuntimeException("FileName mismatch in XML and PDF extracted file"); } String hashVal = grantApplicationHashService.computeAttachmentHash(fileBytes); hashNode = lstHashValue.item(index); hashNodeMap = hashNode.getAttributes(); Node temp = document.createTextNode(hashVal); hashNode.appendChild(temp); hashNode = hashNodeMap.getNamedItem("glob:hashAlgorithm"); hashNode.setNodeValue(InfastructureConstants.HASH_ALGORITHM); fileNode = lstFileLocation.item(index); fileNodeMap = fileNode.getAttributes(); fileNode = fileNodeMap.getNamedItem("att:href"); contentId = fileNode.getNodeValue(); String encodedContentId = cleanContentId(contentId); fileNode.setNodeValue(encodedContentId); mimeTypeNode = lstMimeType.item(0); String contentType = mimeTypeNode.getFirstChild().getNodeValue(); BudgetSubAwardAttachment budgetSubAwardAttachmentBean = new BudgetSubAwardAttachment(); budgetSubAwardAttachmentBean.setData(fileBytes); budgetSubAwardAttachmentBean.setName(encodedContentId); budgetSubAwardAttachmentBean.setType(contentType); budgetSubAwardAttachmentBean.setBudgetSubAward(budgetSubAwardBean); attachmentList.add(budgetSubAwardAttachmentBean); } budgetSubAwardBean.setBudgetSubAwardAttachments(attachmentList); javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance() .newTransformer(); transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(bos); javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(document); transformer.transform(source, result); budgetSubAwardBean.setSubAwardXmlFileData(new String(bos.toByteArray())); bos.close(); return budgetSubAwardBean; }
From source file:org.kuali.coeus.propdev.impl.budget.subaward.PropDevPropDevBudgetSubAwardServiceImpl.java
protected void removeAllEmptyNodes(Document document, String xpath, int parentLevel) throws TransformerException { NodeList emptyElements = XPathAPI.selectNodeList(document, xpath); for (int i = emptyElements.getLength() - 1; i > -1; i--) { Node nodeToBeRemoved = emptyElements.item(i); int hierLevel = parentLevel; while (hierLevel-- > 0) { nodeToBeRemoved = nodeToBeRemoved.getParentNode(); }//from ww w. j ava2s .co m nodeToBeRemoved.getParentNode().removeChild(nodeToBeRemoved); } NodeList moreEmptyElements = XPathAPI.selectNodeList(document, xpath); if (moreEmptyElements.getLength() > 0) { removeAllEmptyNodes(document, xpath, parentLevel); } }
From source file:org.kuali.kra.proposaldevelopment.budget.service.impl.BudgetSubAwardServiceImpl.java
/** * updates the XMl with hashcode for the files *///from w w w.ja v a 2 s. c o m protected BudgetSubAwards updateXML(byte xmlContents[], Map fileMap, BudgetSubAwards budgetSubAwardBean) throws Exception { javax.xml.parsers.DocumentBuilderFactory domParserFactory = javax.xml.parsers.DocumentBuilderFactory .newInstance(); javax.xml.parsers.DocumentBuilder domParser = domParserFactory.newDocumentBuilder(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xmlContents); org.w3c.dom.Document document = domParser.parse(byteArrayInputStream); byteArrayInputStream.close(); String namespace = null; if (document != null) { Node node; String formName; Element element = document.getDocumentElement(); NamedNodeMap map = element.getAttributes(); String namespaceHolder = element.getNodeName().substring(0, element.getNodeName().indexOf(':')); node = map.getNamedItem("xmlns:" + namespaceHolder); namespace = node.getNodeValue(); FormMappingInfo formMappingInfo = new FormMappingLoader().getFormInfo(namespace); formName = formMappingInfo.getFormName(); budgetSubAwardBean.setNamespace(namespace); budgetSubAwardBean.setFormName(formName); } String xpathEmptyNodes = "//*[not(node()) and local-name(.) != 'FileLocation' and local-name(.) != 'HashValue']"; String xpathOtherPers = "//*[local-name(.)='ProjectRole' and local-name(../../.)='OtherPersonnel' and count(../NumberOfPersonnel)=0]"; removeAllEmptyNodes(document, xpathEmptyNodes, 0); removeAllEmptyNodes(document, xpathOtherPers, 1); removeAllEmptyNodes(document, xpathEmptyNodes, 0); changeDataTypeForNumberOfOtherPersons(document); List<String> fedNonFedSubAwardForms = getFedNonFedSubawardForms(); NodeList budgetYearList = XPathAPI.selectNodeList(document, "//*[local-name(.) = 'BudgetYear']"); for (int i = 0; i < budgetYearList.getLength(); i++) { Node bgtYearNode = budgetYearList.item(i); String period = getValue(XPathAPI.selectSingleNode(bgtYearNode, "BudgetPeriod")); if (fedNonFedSubAwardForms.contains(namespace)) { Element newBudgetYearElement = copyElementToName((Element) bgtYearNode, bgtYearNode.getNodeName()); bgtYearNode.getParentNode().replaceChild(newBudgetYearElement, bgtYearNode); } else { Element newBudgetYearElement = copyElementToName((Element) bgtYearNode, bgtYearNode.getNodeName() + period); bgtYearNode.getParentNode().replaceChild(newBudgetYearElement, bgtYearNode); } } Node oldroot = document.removeChild(document.getDocumentElement()); Node newroot = document.appendChild(document.createElement("Forms")); newroot.appendChild(oldroot); org.w3c.dom.NodeList lstFileName = document.getElementsByTagName("att:FileName"); org.w3c.dom.NodeList lstFileLocation = document.getElementsByTagName("att:FileLocation"); org.w3c.dom.NodeList lstMimeType = document.getElementsByTagName("att:MimeType"); org.w3c.dom.NodeList lstHashValue = document.getElementsByTagName("glob:HashValue"); if ((lstFileName.getLength() != lstFileLocation.getLength()) || (lstFileLocation.getLength() != lstHashValue.getLength())) { // throw new RuntimeException("Tag occurances mismatch in XML File"); } org.w3c.dom.Node fileNode, hashNode, mimeTypeNode; org.w3c.dom.NamedNodeMap fileNodeMap, hashNodeMap; String fileName; byte fileBytes[]; String contentId; List attachmentList = new ArrayList(); for (int index = 0; index < lstFileName.getLength(); index++) { fileNode = lstFileName.item(index); Node fileNameNode = fileNode.getFirstChild(); fileName = fileNameNode.getNodeValue(); fileBytes = (byte[]) fileMap.get(fileName); if (fileBytes == null) { throw new RuntimeException("FileName mismatch in XML and PDF extracted file"); } String hashVal = GrantApplicationHash.computeAttachmentHash(fileBytes); hashNode = lstHashValue.item(index); hashNodeMap = hashNode.getAttributes(); Node temp = document.createTextNode(hashVal); hashNode.appendChild(temp); hashNode = hashNodeMap.getNamedItem("glob:hashAlgorithm"); hashNode.setNodeValue(S2SConstants.HASH_ALGORITHM); fileNode = lstFileLocation.item(index); fileNodeMap = fileNode.getAttributes(); fileNode = fileNodeMap.getNamedItem("att:href"); contentId = fileNode.getNodeValue(); String encodedContentId = cleanContentId(contentId); fileNode.setNodeValue(encodedContentId); mimeTypeNode = lstMimeType.item(0); String contentType = mimeTypeNode.getFirstChild().getNodeValue(); BudgetSubAwardAttachment budgetSubAwardAttachmentBean = new BudgetSubAwardAttachment(); budgetSubAwardAttachmentBean.setAttachment(fileBytes); budgetSubAwardAttachmentBean.setContentId(encodedContentId); budgetSubAwardAttachmentBean.setContentType(contentType); budgetSubAwardAttachmentBean.setBudgetId(budgetSubAwardBean.getBudgetId()); budgetSubAwardAttachmentBean.setSubAwardNumber(budgetSubAwardBean.getSubAwardNumber()); attachmentList.add(budgetSubAwardAttachmentBean); } budgetSubAwardBean.setBudgetSubAwardAttachments(attachmentList); javax.xml.transform.Transformer transformer = javax.xml.transform.TransformerFactory.newInstance() .newTransformer(); transformer.setOutputProperty(javax.xml.transform.OutputKeys.INDENT, "yes"); ByteArrayOutputStream bos = new ByteArrayOutputStream(); javax.xml.transform.stream.StreamResult result = new javax.xml.transform.stream.StreamResult(bos); javax.xml.transform.dom.DOMSource source = new javax.xml.transform.dom.DOMSource(document); transformer.transform(source, result); budgetSubAwardBean.setSubAwardXmlFileData(new String(bos.toByteArray())); bos.close(); return budgetSubAwardBean; }
From source file:org.kuali.rice.krad.devtools.maintainablexml.MaintainableXMLConversionServiceImpl.java
public void removePersonObjects(Document doc) { XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression personProperties = null; try {//from w w w.j a v a2 s.c om personProperties = xpath.compile("//*[@class='org.kuali.rice.kim.impl.identity.PersonImpl']"); NodeList matchingNodes = (NodeList) personProperties.evaluate(doc, XPathConstants.NODESET); for (int i = 0; i < matchingNodes.getLength(); i++) { Node tempNode = matchingNodes.item(i); tempNode.getParentNode().removeChild(tempNode); } } catch (XPathExpressionException e) { e.printStackTrace(); } }
From source file:org.kuali.test.handlers.htmltag.KualiCapitalAssetTagHandler.java
private String getItemNumberForLocation(Element node) { String retval = ""; Node parent = node.getParentNode(); while (Utils.isElement(parent)) { if (Utils.isElement(parent.getParentNode())) { if (Constants.HTML_TAG_TYPE_TABLE.equalsIgnoreCase(parent.getParentNode().getNodeName()) && Constants.HTML_TAG_TYPE_TR.equalsIgnoreCase(parent.getNodeName())) { Element table = (Element) parent.getParentNode(); if (Constants.HTML_TAG_ATTRIBUTE_CLASS_DATATABLE .equalsIgnoreCase(table.getAttribute(Constants.HTML_TAG_ATTRIBUTE_CLASS)) && CAPITAL_ASSET_ITEMS_TABLE_SUMMARY .equalsIgnoreCase(table.getAttribute(Constants.HTML_TAG_ATTRIBUTE_SUMMARY))) { Element sibling = Utils.findPreviousSiblingNode((Element) parent, Constants.HTML_TAG_TYPE_TR); if (sibling != null) { Element td = Utils.findFirstChildNode(sibling, Constants.HTML_TAG_TYPE_TD); if (td != null) { retval = Utils.cleanDisplayText(td); break; }//from w ww . jav a 2 s. c om } } } } parent = parent.getParentNode(); } return retval; }
From source file:org.kuali.test.runner.execution.TestWebClient.java
private HtmlForm getParentForm(HtmlElement e) { HtmlForm retval = null;/*from w w w . j a va 2 s . c o m*/ Node cur = e.getParentNode(); while (cur != null) { if (cur instanceof HtmlForm) { retval = (HtmlForm) cur; break; } cur = cur.getParentNode(); } return retval; }
From source file:org.kuali.test.utils.HtmlDomProcessor.java
private String getIframeParentIds(Element node) { String retval = null;//from w w w . ja va 2 s . c o m Node pnode = node.getParentNode(); List<String> ids = new ArrayList<String>(); while (pnode != null) { if (Constants.HTML_TAG_TYPE_IFRAME.equals(pnode.getNodeName())) { Node idnode = pnode.getAttributes().getNamedItem(Constants.HTML_TAG_ATTRIBUTE_ID); if (idnode != null) { ids.add(idnode.getNodeValue()); } } pnode = pnode.getParentNode(); } if (!ids.isEmpty()) { StringBuilder s = new StringBuilder(128); String comma = ""; for (int i = ids.size() - 1; i >= 0; --i) { s.append(comma); s.append(ids.get(i)); comma = ","; } retval = s.toString(); } return retval; }
From source file:org.kuali.test.utils.Utils.java
/** * * @param node/*from w w w .j a v a 2 s . co m*/ * @param parentTagMatch * @return */ public static boolean isParentTagMatchFailure(Element node, ParentTagMatch parentTagMatch) { boolean retval = false; if ((parentTagMatch != null) && (node != null)) { Set<String> parentTagNames = new HashSet<String>(); StringTokenizer st = new StringTokenizer(parentTagMatch.getParentTagName(), "|"); while (st.hasMoreTokens()) { parentTagNames.add(st.nextToken()); } Element validParent = null; Node parent = node.getParentNode(); // if we are looking for table and this is a tbody ten move up 1 level if (Constants.HTML_TAG_TYPE_TABLE.equalsIgnoreCase(parentTagMatch.getParentTagName()) && Constants.HTML_TAG_TYPE_TBODY.equalsIgnoreCase(parent.getNodeName())) { parent = parent.getParentNode(); } if (isElement(parent)) { if (parentTagNames.contains(parent.getNodeName())) { if (parentTagMatch.getMatchAttributes() != null) { if (parentTagMatch.getMatchAttributes().sizeOfMatchAttributeArray() > 0) { boolean ok = true; for (TagMatchAttribute att : parentTagMatch.getMatchAttributes() .getMatchAttributeArray()) { String parentAttr = ((Element) parent).getAttribute(att.getName()); if (StringUtils.isNotBlank(parentAttr)) { int pos = att.getValue().indexOf('*'); if (pos > -1) { if (pos == 0) { ok = parentAttr.endsWith(att.getValue().substring(1)); } else { String s1 = att.getValue().substring(0, pos); String s2 = att.getValue().substring(pos + 1); ok = (parentAttr.startsWith(s1) && parentAttr.endsWith(s2)); } } else { ok = parentAttr.equalsIgnoreCase(att.getValue()); } } else { ok = false; } if (!ok) { break; } } if (ok) { validParent = (Element) parent; } } } else { validParent = (Element) parent; } } } retval = (validParent == null); } return retval; }