Return-Path: X-Original-To: apmail-commons-issues-archive@minotaur.apache.org Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9A86818CCF for ; Sat, 21 Nov 2015 09:13:11 +0000 (UTC) Received: (qmail 13423 invoked by uid 500); 21 Nov 2015 09:13:11 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 13289 invoked by uid 500); 21 Nov 2015 09:13:11 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 13220 invoked by uid 99); 21 Nov 2015 09:13:11 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 21 Nov 2015 09:13:11 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 0E38D2C1F5E for ; Sat, 21 Nov 2015 09:13:11 +0000 (UTC) Date: Sat, 21 Nov 2015 09:13:11 +0000 (UTC) From: "Uwe Barthel (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (JXPATH-169) getChildNodes() has problems in 3rd level of nesting. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/JXPATH-169?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15020347#comment-15020347 ] Uwe Barthel commented on JXPATH-169: ------------------------------------ As [~vivodamichele@hotmail.com] said, [~rubengerad] Could you provide a small test case? > getChildNodes() has problems in 3rd level of nesting. > ----------------------------------------------------- > > Key: JXPATH-169 > URL: https://issues.apache.org/jira/browse/JXPATH-169 > Project: Commons JXPath > Issue Type: Bug > Affects Versions: 1.2 Final > Environment: Windows, JDK 1.6 > Reporter: Ruben Gerad Mathew > > In the event of using JXPath for reading an XML file, the getChildren() method is not fetching NodeList after 3rd level, and any structure after 3rd level return #text (probably scrambled). > An XMI document with an UML structure was parsed, the objective was to identify all attributes inside a class within a package. The context retrieves a list of pakages, getChildren() gets the classes embedded within it and getChildren() on each node on Class gets both the attributes and operations. > However we are unable to get the tagged values in attributes or look any deeper than 3 levels. I tried to get the name of the attribute and use xpath context lookup, but some reason it keeps failing. > Some bit of the code to help. > private void inspectClasses(String handle, Node eachEntryNode){ > try{ > UmlClass umlClass = new UmlClass(); > umlClass.setClassNamespace(eachEntryNode.getAttributes().getNamedItem("name").getNodeValue()); > umlClass.setXmiId(eachEntryNode.getAttributes().getNamedItem("xmi.id").getNodeValue()); > umlClass.setVisibility(eachEntryNode.getAttributes().getNamedItem("visibility").getNodeValue().toString()); > umlClass.setActiveClass(Boolean.parseBoolean(eachEntryNode.getAttributes().getNamedItem("isActive").getNodeValue().toString())); > umlClass.setAbstractClass(Boolean.parseBoolean(eachEntryNode.getAttributes().getNamedItem("isAbstract").getNodeValue().toString())); > for(int child =0; child if(eachEntryNode.getChildNodes().item(child).getNodeName().equals("UML:ModelElement.taggedValue")){ > umlClass.setTaggedValue(getTaggedValues(eachEntryNode.getChildNodes().item(child).getChildNodes())); > EventLog.clog(this,"["+umlClass.getClassNamespace()+"] Tagged values :"+umlClass.getTaggedValue().size()); > } > if(eachEntryNode.getChildNodes().item(child).getNodeName().equals("UML:Classifier.feature")){ > umlClass.setUmlAttributes(getClassAttributes(handle, eachEntryNode.getChildNodes().item(child))); > EventLog.clog(this,"["+umlClass.getClassNamespace()+"] Tagged values :"+umlClass.getTaggedValue().size()); > } > listClasses.add(umlClass); > } > } > catch(NullPointerException exp){ > } > catch(Exception exp){ > ExceptionLog.clog(this, "Problem validating nodes! Error: "+exp.getMessage()); > } > } > public List getClassAttributes(String handle, Node node){ > List classAttributes = new ArrayList(); > > int child, y; > try{ > Document document=(Document)parsedDocs.get(handle); > JXPathContext context = JXPathContext.newContext(document); > context.setLenient(true); > NodeList childNodes = node.getChildNodes(); > for(child =0; child if(childNodes.item(child).getNodeName().toString().equals("UML:Attribute")){ > Node thisNode = childNodes.item(child); > NodeList listNodes =childNodes.item(child).getChildNodes(); > //List entries= context.selectNodes("//UML:Attribute"); //this was a out of the way attempt to get inside the next level of nested class attribute tag values > EventLog.clog(this, "^^^^^^^^^^^^^^^ "+thisNode.getAttributes().getNamedItem("name").getNodeValue().toString()); > locateAttribute(thisNode.getAttributes().getNamedItem("name").getNodeValue().toString(), listNodes); // unabale to iterate listNodes children. 3rd-4th level missing values and prints only #text as result. > } > //EventLog.clog(this, "*************** "+childNodes.item(child).getNodeName().toString()); > } > }catch(Exception exp){ > ExceptionLog.clog(this,"Problem orgnaizing namespace structure"+exp.getMessage()); > } > return classAttributes; > } -- This message was sent by Atlassian JIRA (v6.3.4#6332)