JTree with XML content expand/collapse problem

Hello all,
I'm having this very weird problem with a JTree I use to display the contents of an XML file. I use the DOM parser (and not JDOM since I want the application to run as an applet as well, and don't want to have any external libraries for the user to download) and have a custom TreeModel and TreeNode implementations to wrap the DOM nodes so that they are displayed by the JTree.
I have also added a popup menu in the tree, for the user to be able to expand/collapse all nodes under the selected one (i.e. a recursive method).
When expandAll is run, everything works fine and the children of the selected node are expanded (and their children and so on).
However, after the expansion when I run the collapseAll function, even though the selected node collapses, when I re-expand it (manually not by expandAll) all of it's children are still fully open! Even if I collapse sub-elements of the node manually and then collapse this node and re-expand it, it "forgets" the state of it's children and shows them fully expanded.
In other words once I use expandAll no matter what I do, the children of this node will be expanded (once I close it and re-open it).
Also after running expandAll the behaviour(!) of the expanded nodes change: i have tree.setToggleClickCount(1); but on the expanded nodes I need to double-click to collapse them.
I believe the problem is related to my implementations of TreeModel and TreeNode but after many-many hours of trying to figure out what's happening I'm desperate... Please help!
Here's my code:
public class XMLTreeNode implements TreeNode 
     //This class wraps a DOM node
    org.w3c.dom.Node domNode;
    protected boolean allowChildren;
    protected Vector children;
    //compressed view (#text).
     private static boolean compress = true;   
    // An array of names for DOM node-types
    // (Array indexes = nodeType() values.)
    static final String[] typeName = {
        "none",
        "Element",
        "Attr",
        "Text",
        "CDATA",
        "EntityRef",
        "Entity",
        "ProcInstr",
        "Comment",
        "Document",
        "DocType",
        "DocFragment",
        "Notation",
    static final int ELEMENT_TYPE =   1;
    static final int ATTR_TYPE =      2;
    static final int TEXT_TYPE =      3;
    static final int CDATA_TYPE =     4;
    static final int ENTITYREF_TYPE = 5;
    static final int ENTITY_TYPE =    6;
    static final int PROCINSTR_TYPE = 7;
    static final int COMMENT_TYPE =   8;
    static final int DOCUMENT_TYPE =  9;
    static final int DOCTYPE_TYPE =  10;
    static final int DOCFRAG_TYPE =  11;
    static final int NOTATION_TYPE = 12;
    // The list of elements to display in the tree
   static String[] treeElementNames = {
        "node",
  // Construct an Adapter node from a DOM node
  public XMLTreeNode(org.w3c.dom.Node node) {
    domNode = node;
  public String toString(){
       if (domNode.hasAttributes()){
            return domNode.getAttributes().getNamedItem("label").getNodeValue();
       }else return domNode.getNodeName();      
  public boolean isLeaf(){ 
       return (this.getChildCount()==0);
  boolean treeElement(String elementName) {
      for (int i=0; i<treeElementNames.length; i++) {
        if ( elementName.equals(treeElementNames)) return true;
return false;
public int getChildCount() {
     if (!compress) {   
return domNode.getChildNodes().getLength();
int count = 0;
for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
org.w3c.dom.Node node = domNode.getChildNodes().item(i);
if (node.getNodeType() == ELEMENT_TYPE
&& treeElement( node.getNodeName() ))
// Note:
// Have to check for proper type.
// The DOCTYPE element also has the right name
++count;
return count;
public boolean getAllowsChildren() {
     // TODO Auto-generated method stub
     return true;
public Enumeration children() {
     // TODO Auto-generated method stub
     return null;
public TreeNode getParent() {
     // TODO Auto-generated method stub
     return null;
public TreeNode getChildAt(int searchIndex) {
org.w3c.dom.Node node =
domNode.getChildNodes().item(searchIndex);
if (compress) {
// Return Nth displayable node
int elementNodeIndex = 0;
for (int i=0; i<domNode.getChildNodes().getLength(); i++) {
node = domNode.getChildNodes().item(i);
if (node.getNodeType() == ELEMENT_TYPE
&& treeElement( node.getNodeName() )
&& elementNodeIndex++ == searchIndex) {
break;
return new XMLTreeNode(node);
public int getIndex(TreeNode tnode) {
     if (tnode== null) {
          throw new IllegalArgumentException("argument is null");
     XMLTreeNode child=(XMLTreeNode)tnode;
     int count = getChildCount();
     for (int i=0; i<count; i++) {
          XMLTreeNode n = (XMLTreeNode)this.getChildAt(i);
          if (child.domNode == n.domNode) return i;
     return -1; // Should never get here.
public class XMLTreeModel2 extends DefaultTreeModel
     private Vector listenerList = new Vector();
     * This adapter converts the current Document (a DOM) into
     * a JTree model.
     private Document document;
     public XMLTreeModel2 (Document doc){
          super(new XMLTreeNode(doc));
          this.document=doc;
     public Object getRoot() {
          //System.err.println("Returning root: " +document);
          return new XMLTreeNode(document);
     public boolean isLeaf(Object aNode) {
          return ((XMLTreeNode)aNode).isLeaf();
     public int getChildCount(Object parent) {
          XMLTreeNode node = (XMLTreeNode) parent;
return node.getChildCount();
     public Object getChild(Object parent, int index) {
XMLTreeNode node = (XMLTreeNode) parent;
return node.getChildAt(index);
     public int getIndexOfChild(Object parent, Object child) {
if (parent==null || child==null )
     return -1;
          XMLTreeNode node = (XMLTreeNode) parent;
return node.getIndex((XMLTreeNode) child);
     public void valueForPathChanged(TreePath path, Object newValue) {
// Null. no changes
     public void addTreeModelListener(TreeModelListener listener) {
          if ( listener != null
&& ! listenerList.contains( listener ) ) {
listenerList.addElement( listener );
     public void removeTreeModelListener(TreeModelListener listener) {
          if ( listener != null ) {
listenerList.removeElement( listener );
     public void fireTreeNodesChanged( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesChanged( e );
     public void fireTreeNodesInserted( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesInserted( e );
     public void fireTreeNodesRemoved( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeNodesRemoved( e );
     public void fireTreeStructureChanged( TreeModelEvent e ) {
Enumeration listeners = listenerList.elements();
while ( listeners.hasMoreElements() ) {
TreeModelListener listener =
(TreeModelListener) listeners.nextElement();
listener.treeStructureChanged( e );
The collapseAll, expandAll code (even though I m pretty sure that's not the problem since they work fine on a normal JTree):
    private void collapseAll(TreePath tp){
         if (tp==null) return;
         Object node=tp.getLastPathComponent();
         TreeModel model=tree.getModel();
         if (!model.isLeaf(node)){
              tree.collapsePath(tp);
              for (int i=0;i<model.getChildCount(node);i++){
              //for (int i = node.childCount()-4;i>=0;i--){
                   collapseAll(tp.pathByAddingChild(model.getChild(node,i)));
              tree.collapsePath(tp);
    private void expandAll(TreePath tp){
         if (tp==null) return;
         Object node=tp.getLastPathComponent();
         TreeModel model=tree.getModel();
         if (!model.isLeaf(node)){
              tree.expandPath(tp);
              for (int i=0;i<model.getChildCount(node);i++){
              //for (int i = node.childCount()-4;i>=0;i--){
                   expandAll(tp.pathByAddingChild(model.getChild(node,i)));

Hi,
Iam not facing this problem. To CollapseAll, I do a tree.getModel().reload() which causes all nodes to get collapsed and remain so even if I reopen them manually.
Hope this helps.
cheers,
vidyut

Similar Messages

  • JTree with XML Content

    Hi Friends,
    I am trying to create a JTree whose data will come from a XML Document. Whenever the tree is refreshed (There is a JPopupMenu on the tree which allows the user to call refresh), the tree must update itself with the underlying XML document. If there is any change in the xml doc, it must be reflected in the tree. However, the tree must not collapse when the refresh is called. For example if I have a tree like this:-
    + Root
        |
        ------ Child #1
        |            |
        |            -------- A
        |            |
        |            -------- B
        |
        +------ Child #2
        |
        ------- Child #3
                    |
                    -------- AAA
                    |
                    -------- BBBThe XML Document for the above tree structure would be:-
    <?xml version="1.0" encoding="UTF-8"?>
    <Root>Root
          <Child> Child #1
                <SubChild>A</SubChild>
                <SubChild>B</SubChild>
          </Child>
          <Child> Child #2
                <SubChild>AA</SubChild>
                <SubChild>BB</SubChild>
          </Child>
          <Child> Child #3
                <SubChild>AAA</SubChild>
                <SubChild>BBB</SubChild>
          </Child>
    </Root>Now if i add another node (CCC) in Child #3 (by adding another Subchild element in the XML document), and click refresh on the tree, the tree should look like:-
    + Root
        |
        ------ Child #1
        |            |
        |            -------- A
        |            |
        |            -------- B
        |
        +------ Child #2
        |
        ------- Child #3
                    |
                    -------- AAA
                    |
                    -------- BBB
                    |
                    -------- CCCHowever, if i am trying to reload the tree model, after reading the XML file, the whole tree collapses.
    Can anyone please help me out with this problem?
    Thanx a lot in advance,
    ~Debopam

    * XMLNode.java
    * Created on December 18, 2004, 4:25 PM
    package debopam.utils.xml;
    import java.util.Enumeration;
    import java.util.NoSuchElementException;
    import java.util.Vector;
    import javax.swing.tree.MutableTreeNode;
    import javax.swing.tree.TreeNode;
    import org.jdom.Element;
    * @author Debopam Ghoshal
    public class XMLNode implements MutableTreeNode
        private Element nodeElement;
        private XMLNode parent;
        /** optional user object */
        transient protected Object     userObject;
        /** true if the node is able to have children */
        protected boolean allowsChildren;
        /** array of children, may be null if this node has no children */
        protected Vector children;
         * An enumeration that is always empty. This is used when an enumeration
         * of a leaf node's children is requested.
        static public final Enumeration<TreeNode> EMPTY_ENUMERATION
                = new Enumeration<TreeNode>()
            public boolean hasMoreElements()
            { return false; }
            public TreeNode nextElement()
                throw new NoSuchElementException("No more elements");
        /** Creates a new instance of XMLNode */
        public XMLNode(Element nodeElement, boolean allowsChildren)
            this.nodeElement = nodeElement;
            this.allowsChildren = allowsChildren;
        public XMLNode(String nodeName, boolean allowsChildren)
            nodeElement = new Element(nodeName);
            this.allowsChildren = allowsChildren;
         * Creates and returns a forward-order enumeration of this node's
         * children.  Modifying this node's child array invalidates any child
         * enumerations created before the modification.
         * @return     an Enumeration of this node's children
        public java.util.Enumeration children()
            if(children == null)
                return EMPTY_ENUMERATION;
            else
                return children.elements();
         * Returns true if this node is allowed to have children.
         * @return     true if this node allows children, else false
        public boolean getAllowsChildren()
            return allowsChildren;
         * Determines whether or not this node is allowed to have children.
         * If <code>allows</code> is false, all of this node's children are
         * removed.
         * <p>
         * Note: By default, a node allows children.
         * @param     allows     true if this node is allowed to have children
        public void setAllowsChildren(boolean allows)
            if (allows != allowsChildren)
                allowsChildren = allows;
                if (!allowsChildren)
                    removeAllChildren();
         * Returns the child at the specified index in this node's child array.
         * @param     index     an index into this node's child array
         * @exception     ArrayIndexOutOfBoundsException     if <code>index</code>
         *                              is out of bounds
         * @return     the TreeNode in this node's child array at  the specified index
        public javax.swing.tree.TreeNode getChildAt(int index)
            if (children == null)
                throw new ArrayIndexOutOfBoundsException("node has no children");
            return (TreeNode)children.elementAt(index);
         * Returns the number of children of this node.
         * @return     an int giving the number of children of this node
        public int getChildCount()
            if (children == null)
                return 0;
            else
                return children.size();
         * Returns the index of the specified child in this node's child array.
         * If the specified node is not a child of this node, returns
         * <code>-1</code>.  This method performs a linear search and is O(n)
         * where n is the number of children.
         * @param     aChild     the TreeNode to search for among this node's children
         * @exception     IllegalArgumentException     if <code>aChild</code>
         *                                   is null
         * @return     an int giving the index of the node in this node's child
         *          array, or <code>-1</code> if the specified node is a not
         *          a child of this node
        public int getIndex(TreeNode aChild)
            if (aChild == null)
                throw new IllegalArgumentException("argument is null");
            if (!isNodeChild(aChild))
                return -1;
            return children.indexOf(aChild);     // linear search
         * Returns this node's parent or null if this node has no parent.
         * @return     this node's parent TreeNode, or null if this node has no parent
        public TreeNode getParent()
            return parent;
         * Removes <code>newChild</code> from its present parent (if it has a
         * parent), sets the child's parent to this node, and then adds the child
         * to this node's child array at index <code>childIndex</code>.
         * <code>newChild</code> must not be null and must not be an ancestor of
         * this node.
         * @param     newChild     the MutableTreeNode to insert under this node
         * @param     childIndex     the index in this node's child array
         *                    where this node is to be inserted
         * @exception     ArrayIndexOutOfBoundsException     if
         *                    <code>childIndex</code> is out of bounds
         * @exception     IllegalArgumentException     if
         *                    <code>newChild</code> is null or is an
         *                    ancestor of this node
         * @exception     IllegalStateException     if this node does not allow
         *                              children
         * @see     #isNodeDescendant
        public void insert(MutableTreeNode newChild, int childIndex)
            if (!allowsChildren)
                throw new IllegalStateException("node does not allow children");
            else if (newChild == null)
                throw new IllegalArgumentException("new child is null");
            else if (isNodeAncestor(newChild))
                throw new IllegalArgumentException("new child is an ancestor");
            MutableTreeNode oldParent = (MutableTreeNode)newChild.getParent();
            if (oldParent != null)
                oldParent.remove(newChild);
            newChild.setParent(this);
            if (children == null)
                children = new Vector();
            children.insertElementAt(newChild, childIndex);
        public boolean isLeaf()
            return !nodeElement.hasChildren();
         * Removes the child at the specified index from this node's children
         * and sets that node's parent to null. The child node to remove
         * must be a <code>MutableTreeNode</code>.
         * @param     childIndex     the index in this node's child array
         *                    of the child to remove
         * @exception     ArrayIndexOutOfBoundsException     if
         *                    <code>childIndex</code> is out of bounds
        public void remove(int childIndex)
            MutableTreeNode child = (MutableTreeNode)getChildAt(childIndex);
            children.removeElementAt(childIndex);
            child.setParent(null);
         * Removes <code>aChild</code> from this node's child array, giving it a
         * null parent.
         * @param     aChild     a child of this node to remove
         * @exception     IllegalArgumentException     if <code>aChild</code>
         *                         is null or is not a child of this node
        public void remove(MutableTreeNode aChild)
            if (aChild == null)
                throw new IllegalArgumentException("argument is null");
            if (!isNodeChild(aChild))
                throw new IllegalArgumentException("argument is not a child");
            remove(getIndex(aChild));     // linear search
         * Removes the subtree rooted at this node from the tree, giving this
         * node a null parent.  Does nothing if this node is the root of its
         * tree.
        public void removeFromParent()
            MutableTreeNode parent = (MutableTreeNode)getParent();
            if (parent != null)
                parent.remove(this);
         * Sets this node's parent to <code>newParent</code> but does not
         * change the parent's child array.  This method is called from
         * <code>insert()</code> and <code>remove()</code> to
         * reassign a child's parent, it should not be messaged from anywhere
         * else.
         * @param     newParent     this node's new parent
        public void setParent(MutableTreeNode mutableTreeNode)
            this.parent = parent;
        public void setUserObject(Object obj)
            this.userObject = obj;
        public Element getXMLElement()
            return this.nodeElement;
        public String toString()
            return this.nodeElement.getTextTrim();
         * Returns true if <code>anotherNode</code> is an ancestor of this node
         * -- if it is this node, this node's parent, or an ancestor of this
         * node's parent.  (Note that a node is considered an ancestor of itself.)
         * If <code>anotherNode</code> is null, this method returns false.  This
         * operation is at worst O(h) where h is the distance from the root to
         * this node.
         * @see          #isNodeDescendant
         * @see          #getSharedAncestor
         * @param     anotherNode     node to test as an ancestor of this node
         * @return     true if this node is a descendant of <code>anotherNode</code>
        public boolean isNodeAncestor(TreeNode anotherNode)
            if (anotherNode == null)
                return false;
            TreeNode ancestor = this;
            do
                if (ancestor == anotherNode)
                    return true;
            } while((ancestor = ancestor.getParent()) != null);
            return false;
         * Returns true if <code>aNode</code> is a child of this node.  If
         * <code>aNode</code> is null, this method returns false.
         * @return     true if <code>aNode</code> is a child of this node; false if
         *            <code>aNode</code> is null
        public boolean isNodeChild(TreeNode aNode)
            boolean retval;
            if (aNode == null)
                retval = false;
            else
                if (getChildCount() == 0)
                    retval = false;
                else
                    retval = (aNode.getParent() == this);
            return retval;
         * Removes all of this node's children, setting their parents to null.
         * If this node has no children, this method does nothing.
        public void removeAllChildren()
            for (int i = getChildCount()-1; i >= 0; i--)
                remove(i);
         * Removes <code>newChild</code> from its parent and makes it a child of
         * this node by adding it to the end of this node's child array.
         * @see          #insert
         * @param     newChild     node to add as a child of this node
         * @exception     IllegalArgumentException    if <code>newChild</code>
         *                              is null
         * @exception     IllegalStateException     if this node does not allow
         *                              children
        public void add(MutableTreeNode newChild)
            if(newChild != null && newChild.getParent() == this)
                insert(newChild, getChildCount() - 1);
            else
                insert(newChild, getChildCount());
         * Indicates whether some other object is "equal to" this one.
         * @param   obj   the reference object with which to compare.
         * @return  <code>true</code> if this object is the same as the obj
         *          argument; <code>false</code> otherwise.
        public boolean equals(XMLNode node)
            boolean retValue;
            retValue = (this.getXMLElement().getTextTrim().equals(node.getXMLElement().getTextTrim())) &&
                    (this.getXMLElement().getParent().getTextTrim().equals(node.getXMLElement().getParent().getTextTrim()));
            return retValue;
    * XMLTreeModel.java
    * Created on December 20, 2004, 11:29 AM
    package debopam.utils.xml;
    import java.io.File;
    import java.io.IOException;
    import java.io.ObjectInputStream;
    import java.io.ObjectOutputStream;
    import java.io.Serializable;
    import java.util.EventListener;
    import java.util.List;
    import java.util.Vector;
    import javax.swing.event.EventListenerList;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.TreeModel;
    import javax.swing.tree.TreePath;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    * @author Debopam Ghoshal
    public class XMLTreeModel implements TreeModel
        private XMLNode rootNode;
        private String xmlFileName;
        private Document xmlDocument;
        /** Listeners. */
        protected EventListenerList listenerList = new EventListenerList();
         * Determines how the <code>isLeaf</code> method figures
         * out if a node is a leaf node. If true, a node is a leaf
         * node if it does not allow children. (If it allows
         * children, it is not a leaf node, even if no children
         * are present.) That lets you distinguish between <i>folder</i>
         * nodes and <i>file</i> nodes in a file system, for example.
         * <p>
         * If this value is false, then any node which has no
         * children is a leaf node, and any node may acquire
         * children.
         * @see TreeNode#getAllowsChildren
         * @see TreeModel#isLeaf
         * @see #setAsksAllowsChildren
        protected boolean asksAllowsChildren;
        /** Creates a new instance of XMLTreeModel */
        public XMLTreeModel(String xmlFileName, boolean asksAllowsChildren)
            this.xmlFileName = xmlFileName;
            this.asksAllowsChildren = asksAllowsChildren;
            loadXMLDocument();
            rootNode = makeRootNode();
        public XMLTreeModel(String xmlFileName)
            this(xmlFileName, false);
        private void loadXMLDocument()
            System.out.println("loading xml document...");
            try
                this.xmlDocument = null;
                this.xmlDocument = new SAXBuilder().build(new File(xmlFileName));
            catch(Exception x)
                System.out.println("Error while loading XML Document.");
                x.printStackTrace();
        private XMLNode makeRootNode()
            XMLNode root = new XMLNode(xmlDocument.getRootElement(), true);
            addChildren(root, xmlDocument.getRootElement());
            return root;
        private void addChildren(XMLNode parentXMLNode, Element element)
            List children = element.getChildren();
            for(int i = 0; i < children.size(); i++)
                Element childElement = (Element)children.get(i);
                XMLNode childNode = new XMLNode(childElement, true);
                parentXMLNode.add(childNode);
                addChildren(childNode, childElement);
         * Sets whether or not to test leafness by asking getAllowsChildren()
         * or isLeaf() to the TreeNodes.  If newvalue is true, getAllowsChildren()
         * is messaged, otherwise isLeaf() is messaged.
        public void setAsksAllowsChildren(boolean newValue)
            asksAllowsChildren = newValue;
         * Tells how leaf nodes are determined.
         * @return true if only nodes which do not allow children are
         *         leaf nodes, false if nodes which have no children
         *         (even if allowed) are leaf nodes
         * @see #asksAllowsChildren
        public boolean asksAllowsChildren()
            return asksAllowsChildren;
         * Returns the child of <I>parent</I> at index <I>index</I> in the parent's
         * child array.  <I>parent</I> must be a node previously obtained from
         * this data source. This should not return null if <i>index</i>
         * is a valid index for <i>parent</i> (that is <i>index</i> >= 0 &&
         * <i>index</i> < getChildCount(<i>parent</i>)).
         * @param   parent  a node in the tree, obtained from this data source
         * @return  the child of <I>parent</I> at index <I>index</I>
        public Object getChild(Object parent, int index)
            return ((XMLNode)parent).getChildAt(index);
         * Returns the number of children of <I>parent</I>.  Returns 0 if the node
         * is a leaf or if it has no children.  <I>parent</I> must be a node
         * previously obtained from this data source.
         * @param   parent  a node in the tree, obtained from this data source
         * @return  the number of children of the node <I>parent</I>
        public int getChildCount(Object parent)
            return ((XMLNode)parent).getChildCount();
         * Returns the index of child in parent.
         * If either the parent or child is <code>null</code>, returns -1.
         * @param parent a note in the tree, obtained from this data source
         * @param child the node we are interested in
         * @return the index of the child in the parent, or -1
         *    if either the parent or the child is <code>null</code>
        public int getIndexOfChild(Object parent, Object child)
            if(parent == null || child == null)
                return -1;
            return ((XMLNode)parent).getIndex((XMLNode)child);
         * Sets the root to <code>root</code>. A null <code>root</code> implies
         * the tree is to display nothing, and is legal.
        public void setRoot(XMLNode rootNode)
            Object oldRoot = this.rootNode;
            this.rootNode = rootNode;
            if (rootNode == null && oldRoot != null)
                fireTreeStructureChanged(this, null);
            else
                nodeStructureChanged(rootNode);
         * Returns the root of the tree.  Returns null only if the tree has
         * no nodes.
         * @return  the root of the tree
        public Object getRoot()
            return rootNode;
         * Returns whether the specified node is a leaf node.
         * The way the test is performed depends on the
         * <code>askAllowsChildren</code> setting.
         * @param node the node to check
         * @return true if the node is a leaf node
         * @see #asksAllowsChildren
         * @see TreeModel#isLeaf
        public boolean isLeaf(Object node)
            if(asksAllowsChildren)
                return !((XMLNode)node).getAllowsChildren();
            return ((XMLNode)node).isLeaf();
         * This sets the user object of the TreeNode identified by path
         * and posts a node changed.  If you use custom user objects in
         * the TreeModel you're going to need to subclass this and
         * set the user object of the changed node to something meaningful.
        public void valueForPathChanged(TreePath path, Object newValue)
            XMLNode aNode = (XMLNode)path.getLastPathComponent();
            aNode.setUserObject(newValue);
            nodeChanged(aNode);
         * Invoked this to insert newChild at location index in parents children.
         * This will then message nodesWereInserted to create the appropriate
         * event. This is the preferred way to add children as it will create
         * the appropriate event.
        public void insertNodeInto(XMLNode newChild, XMLNode parent, int index)
            parent.insert(newChild, index);
            int[] newIndexs = new int[1];
            newIndexs[0] = index;
            nodesWereInserted(parent, newIndexs);
         * Message this to remove node from its parent. This will message
         * nodesWereRemoved to create the appropriate event. This is the
         * preferred way to remove a node as it handles the event creation
         * for you.
        public void removeNodeFromParent(XMLNode node)
            XMLNode parent = (XMLNode)node.getParent();
            if(parent == null)
                throw new IllegalArgumentException("node does not have a parent.");
            int[] childIndex = new int[1];
            Object[] removedArray = new Object[1];
            childIndex[0] = parent.getIndex(node);
            parent.remove(childIndex[0]);
            removedArray[0] = node;
            nodesWereRemoved(parent, childIndex, removedArray);
         * Invoke this method after you've changed how node is to be
         * represented in the tree.
        public void nodeChanged(XMLNode node)
            if(listenerList != null && node != null)
                XMLNode parent = (XMLNode)node.getParent();
                if(parent != null)
                    int        anIndex = parent.getIndex(node);
                    if(anIndex != -1)
                        int[] cIndexs = new int[1];
                        cIndexs[0] = anIndex;
                        nodesChanged(parent, cIndexs);
                else if (node == getRoot())
                    nodesChanged(node, null);
         * Invoke this method if you've modified the TreeNodes upon which this
         * model depends.  The model will notify all of its listeners that the
         * model has changed.
        public void reload()
            loadXMLDocument();
            XMLNode tempRootNode = makeRootNode();
            if(!tempRootNode.equals(rootNode))
                // Means that the root node itself has changed.
                System.out.println("Root node changed");
                reload(rootNode);
            //else
                checkForNodesChanged(tempRootNode, rootNode);
         * Invoke this method if you've modified the TreeNodes upon which this
         * model depends.  The model will notify all of its listeners that the
         * model has changed below the node <code>node</code> (PENDING).
        public void reload(XMLNode node)
            if(node != null)
                fireTreeStructureChanged(this, getPathToRoot(node), null, null);
         * Invoke this method after you've inserted some TreeNodes into
         * node.  childIndices should be the index of the new elements and
         * must be sorted in ascending order.
        public void nodesWereInserted(XMLNode node, int[] childIndices)
            if(listenerList != null && node != null && childIndices != null
                    && childIndices.length > 0)
                int               cCount = childIndices.length;
                Object[]          newChildren = new Object[cCount];
                for(int counter = 0; counter < cCount; counter++)
                    newChildren[counter] = node.getChildAt(childIndices[counter]);
                fireTreeNodesInserted(this, getPathToRoot(node), childIndices,
                        newChildren);
         * Invoke this method after you've removed some TreeNodes from
         * node.  childIndices should be the index of the removed elements and
         * must be sorted in ascending order. And removedChildren should be
         * the array of the children objects that were removed.
        public void nodesWereRemoved(XMLNode node, int[] childIndices,
                Object[] removedChildren)
            if(node != null && childIndices != null)
                fireTreeNodesRemoved(this, getPathToRoot(node), childIndices,
                        removedChildren);
         * Invoke this method after you've changed how the children identified by
         * childIndicies are to be represented in the tree.
        public void nodesChanged(XMLNode node, int[] childIndices)
            if(node != null)
                if (childIndices != null)
                    int cCount = childIndices.length;
                    if(cCount > 0)
                        Object[] cChildren = new Object[cCount];
                        for(int counter = 0; counter < cCount; counter++)
                            cChildren[counter] = node.getChildAt
                                    (childIndices[counter]);
                        fireTreeNodesChanged(this, getPathToRoot(node),
                                childIndices, cChildren);
                else if (node == getRoot())
                    fireTreeNodesChanged(this, getPathToRoot(node), null, null);
         * Invoke this method if you've totally changed the children of
         * node and its childrens children...  This will post a
         * treeStructureChanged event.
        public void nodeStructureChanged(XMLNode node)
            if(node != null)
                fireTreeStructureChanged(this, getPathToRoot(node), null, null);
         * Builds the parents of node up to and including the root node,
         * where the original node is the last element in the returned array.
         * The length of the returned array gives the node's depth in the
         * tree.
         * @param aNode the TreeNode to get the path for
        public XMLNode[] getPathToRoot(XMLNode aNode)
            return getPathToRoot(aNode, 0);
         * Builds the parents of node up to and including the root node,
         * where the original node is the last element in the returned array.
         * The length of the returned array gives the node's depth in the
         * tree.
         * @param aNode  the TreeNode to get the path for
         * @param depth  an int giving the number of steps already taken towards
         *        the root (on recursive calls), used to size the returned array
         * @return an array of TreeNodes giving the path from the root to the
         *         specified node
        protected XMLNode[] getPathToRoot(XMLNode aNode, int depth)
            XMLNode[] retNodes;
            // This method recurses, traversing towards the root in order
            // size the array. On the way back, it fills in the nodes,
            // starting from the root and working back to the original node.
            /* Check for null, in case someone passed in a null node, or
               they passed in an element that isn't rooted at root. */
            if(aNode == null)
                if(depth == 0)
                    return null;
                else
                    retNodes = new XMLNode[depth];
            else
                depth++;
                if(aNode == rootNode)
                    retNodes = new XMLNode[depth];
                else
                    retNodes = getPathToRoot((XMLNode)aNode.getParent(), depth);
                retNodes[retNodes.length - depth] = aNode;
            return retNodes;
        //  Events
         * Adds a listener for the TreeModelEvent posted after the tree changes.
         * @see     #removeTreeModelListener
         * @param   l       the listener to add
        public void addTreeModelListener(TreeModelListener l)
            listenerList.add(TreeModelListener.class, l);
         * Removes a listener previously added with <B>addTreeModelListener()</B>.
         * @see     #addTreeModelListener
         * @param   l       the listener to remove
        public void removeTreeModelListener(TreeModelListener l)
            listenerList.remove(TreeModelListener.class, l);
         * Returns an array of all the tree model listeners
         * registered on this model.
         * @return all of this model's <code>TreeModelListener</code>s
         *         or an empty
         *         array if no tree model listeners are currently registered
         * @see #addTreeModelListener
         * @see #removeTreeModelListener
         * @since 1.4
        public TreeModelListener[] getTreeModelListeners()
            return (TreeModelListener[])listenerList.getListeners(
                    TreeModelListener.class);
         * Notifies all listeners that have registered interest for
         * notification on this event type.  The event instance
         * is lazily created using the parameters passed into
         * the fire method.
         * @param source the node being changed
         * @param path the path to the root node
         * @param childIndices the indices of the changed elements
         * @param children the changed elements
         * @see EventListenerList
        protected void fireTreeNodesChanged(Object source, Object[] path,
                int[] childIndices,
                Object[] children)
            // Guaranteed to return a non-null array
            Object[] listeners = listenerList.getListenerList();
            TreeModelEvent e = null;
            // Process the listeners last to first, notifying
            // those that are interested in this event
            for (int i = listeners.length-2; i>=0; i-=2)
                if (listeners==TreeModelListener.class)
    // Lazily create the event:
    if (e == null)
    e = new TreeModelEvent(source, path,
    childIndices, children);
    ((TreeModelListener)listeners[i+1]).treeNodesChanged(e);
    * Notifies all listeners that have registered interest for
    * notification on this event type. The event instance

  • Polulate Text frames with XML content - PLEASE help me.

    Hi guys,
    I'm trying to import some xml data to an indesign file. Here are the steps I'm doing:
    1- create new document
    2- create master page
    3- create empty text fields in the master to be tagged
    4- import tags from xml
    5- import xml
    then it simply don't auto populate the text fields wiith the xml content.
    I've already spent about 10 hours trying to figure out what can be the problem...
    My structure in indesign (BEFORE importing XML):
    businesscards
    Card
    employeeName
    employeePosition
    employeeAddressln1
    employeeAddressln2
    employeePhone
    employeeEmail
    My structure in indesign (AFTER importing XML):
    businesscards
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    Card <!-- has dropdown arrow with xml content inside -->
    employeeName
    employeePosition
    employeeAddressln1
    employeeAddressln2
    employeePhone
    employeeEmail
    But it doesn't populate the text frames...
    I've already tried to write text in the text frames and tagged them, so I can see those colored brackets. But it doesn't work and makes a mess in the structure.
    Please, can someone help me, do you know a good step by step tutorial online? What am I doing wrong?
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <businesscards>
    <Card>
    <!-- contents of Suzan Reed -->
    <employeeName>Suzan Reed</employeeName>
    <employeePosition>Director of Marketing</employeePosition>
    <employeeAddressln1>506 SE 72nd Avenue</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97215</employeeAddressln2>
    <employeePhone>503-481-5858 direct</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Gabriel Powell -->
    <employeeName>Gabriel Powell</employeeName>
    <employeePosition>Senior Training Director</employeePosition>
    <employeeAddressln1>25 NW 23rd Place, Suite 6-122</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97210</employeeAddressln2>
    <employeePhone>503-515-5404 direct</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Dale Erwing -->
    <employeeName>Dale Erwing</employeeName>
    <employeePosition>Trainer</employeePosition>
    <employeeAddressln1>5131 Buffalo Ave. #20</employeeAddressln1>
    <employeeAddressln2>Sherman Oaks, CA 91423</employeeAddressln2>
    <employeePhone>310-795-8943 cell</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    <Card>
    <!-- contents of Jim Conner -->
    <employeeName>Jim Conner</employeeName>
    <employeePosition>Trainer</employeePosition>
    <employeeAddressln1>25 NW 23rd Place, Suite 6-122</employeeAddressln1>
    <employeeAddressln2>Portland, Oregon 97210</employeeAddressln2>
    <employeePhone>503-515-2376 cell</employeePhone>
    <employeeEmail>[email protected]</employeeEmail>
    </Card>
    </businesscards>
    Thanks in advance

    It worked! thanks ... But...
    But only if I don't apply to the Master when I apply to the master all the other cards have the same content as the first of the XML. :(
    Even when I try to create multiple pages (cards) with no Master page (too time consuming), I can't figure out a way of having the other cards filed with the remaining data of the XML. :(
    I don't want to drag the elements one by one to every single card (they are so many...)
    Is there a way of having the structure organized in a way to have indesign auto populate and auto create pages?
    thanks for any kind of advice.

  • How to display string with XML content in 4.6?

    Hi,
    I`d like to know how to display string with XML content in it for 4.6.
    4.6 has not method parse_string.
    And example like this is not helpful:
      DATA: lo_mxml    TYPE REF TO cl_xml_document.
      CREATE OBJECT lo_mxml.
      CALL METHOD lo_mxml->parse_string
        EXPORTING
          stream = gv_xml_string.
      CALL METHOD lo_mxml->display.
    Thank you.

    Hi,
    May be you can use fm SAP_CONVERT_TO_XML_FORMAT. But it have some issues with memory usage, the program consumed tons of memory during convert.

  • Issues with XML Content and Actions to import RRA in FPN (EP7 SPS13)

    Hi,
    I am having trouble using the import functionality of XML Content and Actions to transport Remote Role Assignments between Consumer Portals. Whenever I want to upload an XML file containing RRA for Roles and Groups that were already assigned to eachother, the import fails and nothing is updated. The error I get:
    UMException. Data could not commit to Role: gp:/[full ID of portal role]
    Anyone with experience in how to use this?
    Kind regards,
    Christian Staalby

    hi,
    @Maksim :
    When user launch an URL like http://myserver:port/irj/portal/ import/*filename=C:\test.xml, he is requested to provide username and password; as this link is a shortcut for the upload xml page, there is a check of authorization and only portal admin that have authorization and permission on this page/iview will be able to upload xml file through the URL. Hope this clarify.
    @Kumar :
    thank you for your answer. What a pity to not be able to pass parameter through standard portal page/iview particularly knowing that we can pass paramater through many kinds of iviews (transactional iview, url iview, VC iview...). I explored some option on file com.sap.portal.ivs.init.par but this was unsuccessful. However, thanks to this [link bellow|http://wiki.sdn.sap.com/wiki/display/Snippets/ComponenttouploadXMLfilewithPCD+objects], I was able to upload through URL the XML file.
    The problem is that I can upload only XML file that are stored in the server not in the local user computer. My requirement is to be able to upload local XML file stored on user's computer.
    If someone could provide and idea/solution, I would be very grateful.
    Cheers

  • Xml report Expand/Collapse option

    Is there a way to show the results in the xml report in 'Collapsed form' by default, when I view report? (Report format-ATML 5.0 standard report, Style sheet - tr5_report.xsl)
    I have many steps in my test sequence and the report is quite long. Because the results of all the steps and sub steps are in Expanded view by default, it is very difficult to see the results of a particular step and I have to scroll a lot.
    An option to collapse all the step results at once, even after opening the report would also be helpful for me.

    Try using tr5_horizontal.xsl or tr5_expand.xsl stylesheet for the ATML 5.0 report. Both stylesheet has expand and collapse functionality.
    Also, if you dont want any of the steps to be displayed in report, you can disable result logging for the step or use result filtering expression in Report Option to filter the step result in report.
    - Shashidhar

  • POST http(s) request with xml content in Power Query

    I have a POST http request which works good in HttpRequester (Firefox plugin). I know that it is possible to call POST request in Power Query but cannot find working solution. Here is the original request:
    POST https://svcs.ebay.com/FeedbackService
    X-EBAY-SOA-OPERATION-NAME: createDSRSummaryByPeriod
    X-EBAY-SOA-SERVICE-VERSION: 1.0.0
    X-EBAY-SOA-SERVICE-NAME: FeedbackService
    X-EBAY-SOA-APP-NAME: ***
    X-EBAY-SOA-SITEID: 0
    X-EBAY-SOA-SECURITY-TOKEN: ***
    Content-Type: text/xml
    <?xml version="1.0" encoding="UTF-8"?>
    <createDSRSummaryByPeriodRequest xmlns="http://www.ebay.com/marketplace/services">
    <dateRange>
    <dateFrom>2013-12-01T00:00:00.000Z</dateFrom>
    <dateTo>2013-12-31T23:59:59.999Z</dateTo>
    </dateRange>
    <dateRangeEventType>ListingDate</dateRangeEventType>
    </createDSRSummaryByPeriodRequest>
    Power Query WebContent() function is capable to handle headers and xml content, however, there is no any documentation about its syntax.
    In Power Query I use this request:
    = Xml.Tables(Web.Contents(“https://svcs.ebay.com/FeedbackService”,
    [Headers =[" X-EBAY-SOA-OPERATION-NAME"= "createDSRSummaryByPeriod",
    "X-EBAY-SOA-SERVICE-VERSION="1.0.0",
    "X-EBAY-SOA-SERVICE-NAME"="FeedbackService",
    "X-EBAY-SOA-APP-NAME"="***","X-EBAY-SOA-SITEID"="0",
    "X-EBAY-SOA-SECURITY-TOKEN"="***"],
    Content=["<?xml version="1.0" encoding="UTF-8"?>
    <createDSRSummaryByPeriodRequest xmlns="http://www.ebay.com/marketplace/services">
    <dateRange>
    <dateFrom>2013-12-01T00:00:00.000Z</dateFrom>
    <dateTo>2013-12-31T23:59:59.999Z</dateTo>
    </dateRange>
    <dateRangeEventType>ListingDate</dateRangeEventType>
    </createDSRSummaryByPeriodRequest>"]]))
    However, it returns "Expression.SyntaxError: Invalid identifier." Maybe anyone has at least examples of analogous working syntax?

    Task is solved. First of all I updated PowerQuery since previous version does not support Headers option for Web.Contents function. Here is a correct syntax:
    =Xml.Document(Web.Contents("https://api.ebay.com/ws/api.dll",[Headers=[#"X-EBAY-API-COMPATIBILITY-LEVEL"= "871",#"X-EBAY-API-SITEID"="0",#"X-EBAY-API-CALL-NAME"="GetMyeBaySelling",#"CONTENT-TYPE"="text/xml"], Content=Text.ToBinary("<?xml version="&Character.FromNumber(34)&"1.0"&Character.FromNumber(34)&" encoding="&Character.FromNumber(34)&"utf-8"&Character.FromNumber(34)&"?>
    <GetMyeBaySellingRequest xmlns="&Character.FromNumber(34)&"urn:ebay:apis:eBLBaseComponents"&Character.FromNumber(34)&">
    <RequesterCredentials><eBayAuthToken>***</eBayAuthToken></RequesterCredentials><SoldList><DurationInDays>60</DurationInDays><Pagination><EntriesPerPage>100</EntriesPerPage><PageNumber>1</PageNumber></Pagination></SoldList></GetMyeBaySellingRequest>")]))

  • Issue With ADF Tree Expand/Collapse

    Hi All,
    I have a customer who is having issues using the af:tree component on a deployed application. When he tries to expand or collapse a node of the tree, the icon just blinks. This is occurring not only on our application, but also the Oracle ADF Rich Client Demo on http://jdevadf.oracle.com/adf-richclient-demo/faces/components/tree.jspx. He is using Internet Explorer v7.0.5730.13. As far as I can tell, our browser settings are identical, but I can use the tree without a problem.
    Any ideas as to what the problem could be?
    Thanks,
    Brad

    Unfortunately, Internet Explorer is the only browser that is authorized to run on his computer.
    Do you know of any specific IE settings that would cause the af:tree not to work?

  • Testing BPM on NWA with XML Content

    Hi SDN team,
    I'm working with SAP NetWeaver CE 7.3.
    I have modeled a BPM (based on the Microsoft OLX Web Service) and try to test it on SAP NetWeaver Administration (NWA). Therefor, I also have created a XML file. But when I upload it, the warning message "Datei kann nicht hochgeladen werden, da die Prozessdefinitions-ID für den Prozess, den Sie starten möchten, nicht übereinstimmt", that means "File cannot be uploaded, because the process definition ID for the process you try to start does not match"
    The XML file:
    <?xml version="1.0" encoding="utf-8"?>
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
      <soap:Header>
      <t:RequestServerVersion Version="Exchange2010_SP2"/>
      </soap:Header>
      <soap:Body>
      <FindFolder Traversal="Shallow" xmlns="http://schemas.microsoft.com/exchange/services/2006/messages">
      <FolderShape>
      <t:BaseShape>AllProperties</t:BaseShape>
      </FolderShape>
      <ParentFolderIds>
      <t:FolderId Id="AAEuAAAAAAAaRHOQqmYRzZvIAKoAL8RaAwAVb4+VoTScSajx6dP/9c40AAACQ1iEAAA="/>
      <t:DistinguishedFolderId Id="inbox"/>
      </ParentFolderIds>
      </FindFolder>
      </soap:Body>
    </soap:Envelope>
    Without the envelope, I got an error: "File not valid".
    Is there another way to define start (parameter) values? In my BPM, there is a Data Content for the process context.
    Thanks, Cheers,
    Cengiz

    Hello Cengiz,
    i don't know if i get this right. You have designed a BPM Workflow with a start trigger based on a microsoft wsdl and you want to test this now? You could start your process in NWA by navigating to Process-Repository and klick on your process definition and then click button "start process". Then you can enter start parameter. Also you could use the WSNavigator and search for your start Trigger. There you could also enter the paramters and start your process.
    BR,
    Tobi

  • Parent Child Hiearchy - Expand/Collapse problems

    Hello,
    We are on 11.1.1.6 and have built a parent child hierarchy on one of our dimensions. Navigation of the hierarchy works just fine if no measures are included. When a measure is added, the hierarchy becomes nearly unnavigable. That is to say clicking on the plus/minus signs doesn't work. Clicking in various locations of the screen can sometimes get it to work but it is ridiculously hard to get anywhere. The fact table from which the measure is pulled is very small, approx. 100,000 rows so we don't see that as the problem.
    Has anybody else seen such a problem?
    Thanks.

    Can you provide more info on this, how have you modeled the hierarchy with the fact table, are you rolling up the measures for the child to the parent level (modeling as measures) or each employee is showing its own revenue only (modeled as attribute)? If it is modeled as measures where you join the employee table to the closure table and then that to fact table then are you applying any filters in your report ? If you are applying filters in your report and somehow only parent is filtered (and not its children) then you won't be able to drill down, though you will see the + sign against it.

  • Populating ComboBox with XML data

    Hi there,
    Probably the most basic question, but I'm having a hard time with this...
    Trying to populate the ComboBox with XML data as a dataProvider.
    Here is the code snippet:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    layout="vertical"
                    creationComplete="baseDataRequest.send()">
        <mx:Script>
            <![CDATA[
                import mx.collections.XMLListCollection;
                import mx.rpc.events.ResultEvent;
                [Bindable]
                private var baseDataXML:XML;
                private function baseResultHandler(event:ResultEvent):void
                    baseDataXML = event.result.node.child as XML;
            ]]>
        </mx:Script>
        <mx:HTTPService id="baseDataRequest"
                        useProxy="false"
                        resultFormat="e4x"
                        result="baseResultHandler(event)"
                        url="XML_URL"/>
        <mx:ComboBox id="comboDemo"
                     width="390"
                     dataProvider="{baseDataXML}"
                     labelField="NodeName"/>
    </mx:Application>
    And that returns nothing, basically. I know the XML is being pulled, because if I do this:
    baseDataXML = event.result as XML;
    then I just see a single item in my ComboBox, with full XML content.
    How do I populate the ComboBox with XML contents?
    XML example:
    <root>
        <node>          <child>Child1</child>
              <child>Child2</child>
         </node>
    </root>
    Question: how do I populate the ComboBox with XML data nodes? I need <child> content to be the labelField of each combo box item...
    Thanks!
    K

         <mx:Script>
              <![CDATA[
                   var baseDataXML:XML = <root><node><child>Child1</child><child>Child2</child></node></root>;
              ]]>
         </mx:Script>
         <mx:ComboBox id="comboDemo"
                     width="390"
                     dataProvider="{baseDataXML.node.child}"
                     labelField="NodeName"/>
    Don't do:
    baseDataXML = event.result.node.child as XML;
    Instead just do:
    baseDataXML = XML(event.result);
    And in your combo:
    dataProvider="{baseDataXML.node.child}"

  • Error message in .docx : 'Open XML file cannot be opened because there are problems with the contents. Details Unspecific error Location: 2'

    I have put a lot of work into a docx document on my Mac, but now can't open it as it gives the error message: 'the Open XML file cannot be opened because there are problems with the contents. Details, Unspecific
    error, Location: 2'
    When opening the original file the message said: 'this file contains word 2007 for Windows equations' etc. but I managed to track changes fine, and saved, closed and re-opened it numerous times without problem. Some graphs seemed moved, and various formulas
    were illegible, but no other weirdness was observed.
    I have microsoft 2008 installed on my Mac OS X version 10.6.8.
    I've tried to fix it using various solutions suggested here, but am afraid am too IT illiterate to have had any luck, please help I'm new to all this!
    I've uploaded it to https://www.dropbox.com/s/hkw9k6lyihzoxpc/SittwayPauktawSQUEACREPORT_KD%2BCH.docx

    Hi,
    This issue is related strictly to oMath tags and occurs when a graphical object or text box is anchored to the same paragraph that contains the equation.
    Please use the "Fix it" tool in the following KB article to resolve the problem. See:
    http://support.microsoft.com/kb/2528942
    Hope this helps.
    Regards,
    Steve Fan
    TechNet Community Support

  • Problem with displaying XML Content well formatted.

    Hi all,
    I am developing a website which have one functionality to display XML content which is received from some other party.
    I am using TextArea for displaying this XML content on my webpage. As this XML content is not at all formatted it looks very ugly for a human to read.
    I want this XML content to be displayed well formatted, As Mozilla Firefox display it hierarchically and well formatted.
    Kindly give some suggestion for displaying XML well formatted on a webpage.
    Any comments from you people will help me.
    Thanks
    typurohit.

    The following link is a XML-based document. An XSL stylesheet transforms the XML document to HTML in the web browser. Feel free to grab a copy of the stylesheet to use as a guide.
    http://www.masonicartbook.com/production.htm
    Good luck!

  • How do I remove expand / collapse icon for JTree empty folders

    Hi
    I am using a JTree as a file system browser. I use DefaultMutableTreeNode nodes.
    I have a problem with empty folders.
    Empty folders show the expand / collapse icon, leading the user to believe there are sub-directories. When the user double-clicks the folder, the expand / collapse icon goes away. This is a "haha-gotcha" glitch that I really don't want my users to have to continually deal with.
    So, how might I get my JTree to not show the expand / collapse icon for empty folders?
    Thanks
    Wayne

    Maybe I can use the FileSystemView isTraversable(File f) method in my TreeCellRenderer class to check if anything is in the directory.
    But I still need to know how to disable the expand / collapse icon for such a node.

  • Trouble with JTree's and autmoatically expanding nodes

    I am writing an application which uses a JTree as a method of browsing through a certain structure (like a file system). I am having a little trouble though, with a number of small issues, which I am finding hard to get answers through searches (and have spent a fair while searching). In navigating the tree, I want to be able to automatically expand nodes.
    Firstly, I want the Root node to automatically be expanded. I cannot see ways of doing this. I have seen references to EXPANDED being set for the JTree constructor, but I cannot see any reference in the 1.6 API for this.
    Secondly, I want to be able to expand or hide the contents of nodes through other means than clicking on the icon to the left of a non-leaf-node. For example a button that would hide the contents of (i.e. close) the currently selected node. Code such as:
    myNode.setExpanded(true);
    myNode.setExpanded(false);and
    myNode.isExpanded();

    That's the ticket - again something I had seen, but had been using in the wrong way, but your suggestion has helped me get it right. I was trying to expand the path before any more nodes were added to the root node. Then nodes are added, and the application loaded with the root node collapsed. So now I have placed the call at the end of the recursive call to populate the tree.
    Thanks again.

Maybe you are looking for

  • How to store music in Macbook?

    Hey guys, I am running version 10.6.3 and would like to store my mp3's in the mac, in windows I would simply go into the C drive and create a folder named my music or mp3's and load my music folders in there and navigate from my music software to the

  • The 4.2 update hasn't completed in 4 hours-whats up?

    Why is this update taking forever?

  • Referencing images via proxy server

    Hi. Has anyone else run into referencing images via an IIS proxy server? I can use the method to get the context path, but it doesn't bring me back something I can use to reference images. Do I have to hard code those in there all the time? :< DOH!

  • Video stalling but Audio OK

    I'm experiencing problems with the Video ramdomly "stalling" or just showing a single frame when playing back videos. The Audio keeps playing but the video "freeze" can happen for a few seconds. It normally just carries on after the glitch. This is h

  • Managing Test Limits in Test Stand

    Hi, We are new to Test Stand, and want to make sure we are setting up our sequence files and supporting files correctly.  When dealing with test limits or the expected value of measurements etc..., what is the best way to manage the expected values a