Java Code Examples for org.dom4j.XPath#setNamespaceURIs()

The following examples show how to use org.dom4j.XPath#setNamespaceURIs() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GetXmlData.java    From hop with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
private boolean applyXPath() {
  try {
    XPath xpath = data.document.createXPath( data.PathValue );
    if ( meta.isNamespaceAware() ) {
      xpath = data.document.createXPath( addNSPrefix( data.PathValue, data.PathValue ) );
      xpath.setNamespaceURIs( data.NAMESPACE );
    }
    // get nodes list
    data.an = xpath.selectNodes( data.document );
    data.nodesize = data.an.size();
    data.nodenr = 0;
  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "GetXMLData.Log.ErrorApplyXPath", e.getMessage() ) );
    return false;
  }
  return true;
}
 
Example 2
Source File: GetXMLData.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings( "unchecked" )
private boolean applyXPath() {
  try {
    XPath xpath = data.document.createXPath( data.PathValue );
    if ( meta.isNamespaceAware() ) {
      xpath = data.document.createXPath( addNSPrefix( data.PathValue, data.PathValue ) );
      xpath.setNamespaceURIs( data.NAMESPACE );
    }
    // get nodes list
    data.an = xpath.selectNodes( data.document );
    data.nodesize = data.an.size();
    data.nodenr = 0;
  } catch ( Exception e ) {
    logError( BaseMessages.getString( PKG, "GetXMLData.Log.ErrorApplyXPath", e.getMessage() ) );
    return false;
  }
  return true;
}
 
Example 3
Source File: MeijoFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private XPath makeFaceNeighbourXPath(int edgeID, int faceID) {
    String path = FACE_NEIGHBOUR_XPATH_STRING.replace("$edgeid", String.valueOf(edgeID)).replace("$faceid", String.valueOf(faceID));
    //        Logger.debug("Neighbour XPath: " + path);
    XPath result = DocumentHelper.createXPath(path);
    result.setNamespaceURIs(URIS);
    return result;
}
 
Example 4
Source File: CPManifestTreeModel.java    From olat with Apache License 2.0 5 votes vote down vote up
private GenericTreeNode buildNode(final Element item) {
    final GenericTreeNode gtn = new GenericTreeNode();

    // extract title
    String title = item.elementText("title");
    if (title == null) {
        title = item.attributeValue("identifier");
    }
    gtn.setAltText(title);
    gtn.setTitle(title);

    if (item.getName().equals("organization")) {
        gtn.setIconCssClass("o_cp_org");
        gtn.setAccessible(false);
    } else if (item.getName().equals("item")) {
        gtn.setIconCssClass("o_cp_item");
        // set resolved file path directly
        final String identifierref = item.attributeValue("identifierref");
        final XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        meta.setNamespaceURIs(nsuris);
        final String href = (String) resources.get(identifierref);
        if (href != null) {
            gtn.setUserObject(href);
            // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
            hrefToTreeNode.put(href, gtn);
        } else {
            gtn.setAccessible(false);
        }
    }

    final List chds = item.elements("item");
    final int childcnt = chds.size();
    for (int i = 0; i < childcnt; i++) {
        final Element childitem = (Element) chds.get(i);
        final GenericTreeNode gtnchild = buildNode(childitem);
        gtn.addChild(gtnchild);
    }
    return gtn;
}
 
Example 5
Source File: CPManifestTreeModel.java    From olat with Apache License 2.0 5 votes vote down vote up
private GenericTreeNode buildNode(final Element item) {
    final GenericTreeNode gtn = new GenericTreeNode();

    // extract title
    String title = item.elementText("title");
    if (title == null) {
        title = item.attributeValue("identifier");
    }
    gtn.setAltText(title);
    gtn.setTitle(title);

    if (item.getName().equals("organization")) {
        gtn.setIconCssClass("o_cp_org");
        gtn.setAccessible(false);
    } else if (item.getName().equals("item")) {
        gtn.setIconCssClass("o_cp_item");
        // set resolved file path directly
        final String identifierref = item.attributeValue("identifierref");
        final XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        meta.setNamespaceURIs(nsuris);
        final String href = (String) resources.get(identifierref);
        if (href != null) {
            gtn.setUserObject(href);
            // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
            hrefToTreeNode.put(href, gtn);
        } else {
            gtn.setAccessible(false);
        }
    }

    final List chds = item.elements("item");
    final int childcnt = chds.size();
    for (int i = 0; i < childcnt; i++) {
        final Element childitem = (Element) chds.get(i);
        final GenericTreeNode gtnchild = buildNode(childitem);
        gtn.addChild(gtnchild);
    }
    return gtn;
}
 
Example 6
Source File: SearchProxy.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
protected void writeResponse(InputStream input, OutputStream output)
    throws IOException
{
    if (response.getContentType().startsWith(MimetypeMap.MIMETYPE_ATOM) ||
        response.getContentType().startsWith(MimetypeMap.MIMETYPE_RSS))
    {
        // Only post-process ATOM and RSS feeds
        // Replace all navigation links with "proxied" versions
        SAXReader reader = new SAXReader();
        try
        {
            Document document = reader.read(input);
            Element rootElement = document.getRootElement();

            XPath xpath = rootElement.createXPath(ATOM_LINK_XPATH);
            Map<String,String> uris = new HashMap<String,String>();
            uris.put(ATOM_NS_PREFIX, ATOM_NS_URI);
            xpath.setNamespaceURIs(uris);

            List nodes = xpath.selectNodes(rootElement);
            Iterator iter = nodes.iterator();
            while (iter.hasNext())
            {
                Element element = (Element)iter.next();
                Attribute hrefAttr = element.attribute("href");
                String mimetype = element.attributeValue("type");
                if (mimetype == null || mimetype.length() == 0)
                {
                    mimetype = MimetypeMap.MIMETYPE_HTML;
                }
                String url = createUrl(engine, hrefAttr.getValue(), mimetype);
                if (url.startsWith("/"))
                {
                    url = rootPath + url;
                }
                hrefAttr.setValue(url);
            }
            
            OutputFormat outputFormat = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(output, outputFormat);
            writer.write(rootElement);
            writer.flush();                
        }
        catch(DocumentException e)
        {
            throw new IOException(e.toString());
        }
    }
    else
    {
        super.writeResponse(input, output);
    }
}
 
Example 7
Source File: CPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the content packaging tree model
 * 
 * @param manifest
 *            the imsmanifest.xml file
 */
public CPManifestTreeModel(final VFSLeaf manifest) {
    final Document doc = loadDocument(manifest);
    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    nsuris.put("ns", nsuri);

    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    final Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) {
        throw new AssertException("could not find element organization");
    }

    final XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    final Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AssertException("could not find element resources");
    }

    final List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (final Iterator iter = resourcesList.iterator(); iter.hasNext();) {
        final Element elRes = (Element) iter.next();
        final String identVal = elRes.attributeValue("identifier");
        String hrefVal = elRes.attributeValue("href");
        if (hrefVal != null) { // href is optional element for resource element
            try {
                hrefVal = URLDecoder.decode(hrefVal, "UTF-8");
            } catch (final UnsupportedEncodingException e) {
                // each JVM must implement UTF-8
            }
        }
        resources.put(identVal, hrefVal);
    }
    final GenericTreeNode gtn = buildNode(orgaEl);
    setRootNode(gtn);
    rootElement = null; // help gc
    resources = null;
}
 
Example 8
Source File: ImsCPFileResource.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Check for title and at least one resource.
 * 
 * @param unzippedDir
 * @return True if is of type.
 */
public static boolean validate(final File unzippedDir) throws AddingResourceException {
    final File fManifest = new File(unzippedDir, "imsmanifest.xml");
    final Document doc = IMSLoader.loadIMSDocument(fManifest);
    // do not throw exception already here, as it might be only a generic zip file
    if (doc == null) {
        return false;
    }

    // get all organization elements. need to set namespace
    final Element rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    final Map nsuris = new HashMap(1);
    nsuris.put("ns", nsuri);

    // Check for organiztaion element. Must provide at least one... title gets ectracted from either
    // the (optional) <title> element or the mandatory identifier attribute.
    // This makes sure, at least a root node gets created in CPManifestTreeModel.
    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    final Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) {
        throw new AddingResourceException("resource.no.organisation");
    }

    // Check for at least one <item> element referencing a <resource>, which will serve as an entry point.
    // This is mandatory, as we need an entry point as the user has the option of setting
    // CPDisplayController to not display a menu at all, in which case the first <item>/<resource>
    // element pair gets displayed.
    final XPath resourcesXPath = rootElement.createXPath("//ns:resources");
    resourcesXPath.setNamespaceURIs(nsuris);
    final Element elResources = (Element) resourcesXPath.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AddingResourceException("resource.no.resource"); // no <resources> element.
    }
    final XPath itemsXPath = rootElement.createXPath("//ns:item");
    itemsXPath.setNamespaceURIs(nsuris);
    final List items = itemsXPath.selectNodes(rootElement);
    if (items.size() == 0) {
        throw new AddingResourceException("resource.no.item"); // no <item> element.
    }
    for (final Iterator iter = items.iterator(); iter.hasNext();) {
        final Element item = (Element) iter.next();
        final String identifierref = item.attributeValue("identifierref");
        if (identifierref == null) {
            continue;
        }
        final XPath resourceXPath = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        resourceXPath.setNamespaceURIs(nsuris);
        final Element elResource = (Element) resourceXPath.selectSingleNode(elResources);
        if (elResource == null) {
            throw new AddingResourceException("resource.no.matching.resource");
        }
        if (elResource.attribute("scormtype") != null) {
            return false;
        }
        if (elResource.attribute("scormType") != null) {
            return false;
        }
        if (elResource.attribute("SCORMTYPE") != null) {
            return false;
        }
        if (elResource.attributeValue("href") != null) {
            return true; // success.
        }
    }
    return false;
    // throw new AddingResourceException("resource.general.error");
}
 
Example 9
Source File: ScormCPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the content packaging tree model
 * 
 * @param scormFolderPath
 *            the imsmanifest.xml file
 * @param itemStatus
 *            a Map containing the status of each item like "completed, not attempted, ..."
 */
public ScormCPManifestTreeModel(final String scormFolderPath, final Map itemStatus) {
    ScormEBL scormEbl = CoreSpringFactory.getBean(ScormEBL.class);
    this.itemStatus = itemStatus;
    final Document doc = loadDocument(scormEbl.getManifestFile(scormFolderPath));
    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    nsuris.put("ns", nsuri);

    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);

    final XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    final Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AssertException("could not find element resources");
    }

    final List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (final Iterator iter = resourcesList.iterator(); iter.hasNext();) {
        final Element elRes = (Element) iter.next();
        final String identVal = elRes.attributeValue("identifier");
        String hrefVal = elRes.attributeValue("href");
        if (hrefVal != null) { // href is optional element for resource element
            try {
                hrefVal = URLDecoder.decode(hrefVal, "UTF-8");
            } catch (final UnsupportedEncodingException e) {
                // each JVM must implement UTF-8
            }
        }
        resources.put(identVal, hrefVal);
    }
    /*
     * Get all organizations
     */
    List organizations = new LinkedList();
    organizations = meta.selectNodes(rootElement);
    if (organizations.isEmpty()) {
        throw new AssertException("could not find element organization");
    }
    final GenericTreeNode gtn = buildTreeNodes(organizations);
    setRootNode(gtn);
    rootElement = null; // help gc
    resources = null;
}
 
Example 10
Source File: ScormCPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
private GenericTreeNode buildNode(final Element item) {
    final GenericTreeNode treeNode = new GenericTreeNode();

    // extract title
    String title = item.elementText("title");
    if (title == null) {
        title = item.attributeValue("identifier");
    }
    treeNode.setAltText(title);
    treeNode.setTitle(title);

    if (item.getName().equals("organization")) {
        treeNode.setIconCssClass("o_scorm_org");
        treeNode.setAccessible(false);
    } else if (item.getName().equals("item")) {
        scormIdToNode.put(new Integer(nodeId).toString(), treeNode);
        nodeToId.put(treeNode, new Integer(nodeId));

        // set node images according to scorm sco status
        final String itemStatusDesc = (String) itemStatus.get(Integer.toString(nodeId));
        treeNode.setIconCssClass("o_scorm_item");
        if (itemStatusDesc != null) {
            // add icon decorator for current status
            treeNode.setIconDecorator1CssClass("o_scorm_" + itemStatusDesc);
        }

        nodeId++;
        // set resolved file path directly
        final String identifierref = item.attributeValue("identifierref");
        final XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        meta.setNamespaceURIs(nsuris);
        final String href = (String) resources.get(identifierref);
        if (href != null) {
            treeNode.setUserObject(href);
            // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
            hrefToTreeNode.put(href, treeNode);
        } else {
            treeNode.setAccessible(false);
        }
    }

    final List chds = item.elements("item");
    final int childcnt = chds.size();
    for (int i = 0; i < childcnt; i++) {
        final Element childitem = (Element) chds.get(i);
        final GenericTreeNode gtnchild = buildNode(childitem);
        treeNode.addChild(gtnchild);
    }
    return treeNode;
}
 
Example 11
Source File: CPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the content packaging tree model
 * 
 * @param manifest
 *            the imsmanifest.xml file
 */
public CPManifestTreeModel(final VFSLeaf manifest) {
    final Document doc = loadDocument(manifest);
    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    nsuris.put("ns", nsuri);

    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    final Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) {
        throw new AssertException("could not find element organization");
    }

    final XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    final Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AssertException("could not find element resources");
    }

    final List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (final Iterator iter = resourcesList.iterator(); iter.hasNext();) {
        final Element elRes = (Element) iter.next();
        final String identVal = elRes.attributeValue("identifier");
        String hrefVal = elRes.attributeValue("href");
        if (hrefVal != null) { // href is optional element for resource element
            try {
                hrefVal = URLDecoder.decode(hrefVal, "UTF-8");
            } catch (final UnsupportedEncodingException e) {
                // each JVM must implement UTF-8
            }
        }
        resources.put(identVal, hrefVal);
    }
    final GenericTreeNode gtn = buildNode(orgaEl);
    setRootNode(gtn);
    rootElement = null; // help gc
    resources = null;
}
 
Example 12
Source File: ImsCPFileResource.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Check for title and at least one resource.
 * 
 * @param unzippedDir
 * @return True if is of type.
 */
public static boolean validate(final File unzippedDir) throws AddingResourceException {
    final File fManifest = new File(unzippedDir, "imsmanifest.xml");
    final Document doc = IMSLoader.loadIMSDocument(fManifest);
    // do not throw exception already here, as it might be only a generic zip file
    if (doc == null) {
        return false;
    }

    // get all organization elements. need to set namespace
    final Element rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    final Map nsuris = new HashMap(1);
    nsuris.put("ns", nsuri);

    // Check for organiztaion element. Must provide at least one... title gets ectracted from either
    // the (optional) <title> element or the mandatory identifier attribute.
    // This makes sure, at least a root node gets created in CPManifestTreeModel.
    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);
    final Element orgaEl = (Element) meta.selectSingleNode(rootElement); // TODO: accept several organizations?
    if (orgaEl == null) {
        throw new AddingResourceException("resource.no.organisation");
    }

    // Check for at least one <item> element referencing a <resource>, which will serve as an entry point.
    // This is mandatory, as we need an entry point as the user has the option of setting
    // CPDisplayController to not display a menu at all, in which case the first <item>/<resource>
    // element pair gets displayed.
    final XPath resourcesXPath = rootElement.createXPath("//ns:resources");
    resourcesXPath.setNamespaceURIs(nsuris);
    final Element elResources = (Element) resourcesXPath.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AddingResourceException("resource.no.resource"); // no <resources> element.
    }
    final XPath itemsXPath = rootElement.createXPath("//ns:item");
    itemsXPath.setNamespaceURIs(nsuris);
    final List items = itemsXPath.selectNodes(rootElement);
    if (items.size() == 0) {
        throw new AddingResourceException("resource.no.item"); // no <item> element.
    }
    for (final Iterator iter = items.iterator(); iter.hasNext();) {
        final Element item = (Element) iter.next();
        final String identifierref = item.attributeValue("identifierref");
        if (identifierref == null) {
            continue;
        }
        final XPath resourceXPath = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        resourceXPath.setNamespaceURIs(nsuris);
        final Element elResource = (Element) resourceXPath.selectSingleNode(elResources);
        if (elResource == null) {
            throw new AddingResourceException("resource.no.matching.resource");
        }
        if (elResource.attribute("scormtype") != null) {
            return false;
        }
        if (elResource.attribute("scormType") != null) {
            return false;
        }
        if (elResource.attribute("SCORMTYPE") != null) {
            return false;
        }
        if (elResource.attributeValue("href") != null) {
            return true; // success.
        }
    }
    return false;
    // throw new AddingResourceException("resource.general.error");
}
 
Example 13
Source File: ScormCPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
/**
 * Constructor of the content packaging tree model
 * 
 * @param scormFolderPath
 *            the imsmanifest.xml file
 * @param itemStatus
 *            a Map containing the status of each item like "completed, not attempted, ..."
 */
public ScormCPManifestTreeModel(final String scormFolderPath, final Map itemStatus) {
    ScormEBL scormEbl = CoreSpringFactory.getBean(ScormEBL.class);
    this.itemStatus = itemStatus;
    final Document doc = loadDocument(scormEbl.getManifestFile(scormFolderPath));
    // get all organization elements. need to set namespace
    rootElement = doc.getRootElement();
    final String nsuri = rootElement.getNamespace().getURI();
    nsuris.put("ns", nsuri);

    final XPath meta = rootElement.createXPath("//ns:organization");
    meta.setNamespaceURIs(nsuris);

    final XPath metares = rootElement.createXPath("//ns:resources");
    metares.setNamespaceURIs(nsuris);
    final Element elResources = (Element) metares.selectSingleNode(rootElement);
    if (elResources == null) {
        throw new AssertException("could not find element resources");
    }

    final List resourcesList = elResources.elements("resource");
    resources = new HashMap(resourcesList.size());
    for (final Iterator iter = resourcesList.iterator(); iter.hasNext();) {
        final Element elRes = (Element) iter.next();
        final String identVal = elRes.attributeValue("identifier");
        String hrefVal = elRes.attributeValue("href");
        if (hrefVal != null) { // href is optional element for resource element
            try {
                hrefVal = URLDecoder.decode(hrefVal, "UTF-8");
            } catch (final UnsupportedEncodingException e) {
                // each JVM must implement UTF-8
            }
        }
        resources.put(identVal, hrefVal);
    }
    /*
     * Get all organizations
     */
    List organizations = new LinkedList();
    organizations = meta.selectNodes(rootElement);
    if (organizations.isEmpty()) {
        throw new AssertException("could not find element organization");
    }
    final GenericTreeNode gtn = buildTreeNodes(organizations);
    setRootNode(gtn);
    rootElement = null; // help gc
    resources = null;
}
 
Example 14
Source File: ScormCPManifestTreeModel.java    From olat with Apache License 2.0 4 votes vote down vote up
private GenericTreeNode buildNode(final Element item) {
    final GenericTreeNode treeNode = new GenericTreeNode();

    // extract title
    String title = item.elementText("title");
    if (title == null) {
        title = item.attributeValue("identifier");
    }
    treeNode.setAltText(title);
    treeNode.setTitle(title);

    if (item.getName().equals("organization")) {
        treeNode.setIconCssClass("o_scorm_org");
        treeNode.setAccessible(false);
    } else if (item.getName().equals("item")) {
        scormIdToNode.put(new Integer(nodeId).toString(), treeNode);
        nodeToId.put(treeNode, new Integer(nodeId));

        // set node images according to scorm sco status
        final String itemStatusDesc = (String) itemStatus.get(Integer.toString(nodeId));
        treeNode.setIconCssClass("o_scorm_item");
        if (itemStatusDesc != null) {
            // add icon decorator for current status
            treeNode.setIconDecorator1CssClass("o_scorm_" + itemStatusDesc);
        }

        nodeId++;
        // set resolved file path directly
        final String identifierref = item.attributeValue("identifierref");
        final XPath meta = rootElement.createXPath("//ns:resource[@identifier='" + identifierref + "']");
        meta.setNamespaceURIs(nsuris);
        final String href = (String) resources.get(identifierref);
        if (href != null) {
            treeNode.setUserObject(href);
            // allow lookup of a treenode given a href so we can quickly adjust the menu if the user clicks on hyperlinks within the text
            hrefToTreeNode.put(href, treeNode);
        } else {
            treeNode.setAccessible(false);
        }
    }

    final List chds = item.elements("item");
    final int childcnt = chds.size();
    for (int i = 0; i < childcnt; i++) {
        final Element childitem = (Element) chds.get(i);
        final GenericTreeNode gtnchild = buildNode(childitem);
        treeNode.addChild(gtnchild);
    }
    return treeNode;
}