XML/XSL

Hi,
I want to create a tree view(hierchical view) like in Explorer using XSL by reading the nodes(elements) from my xml file.How can I do this?.Can anyone suggest me a method?.In my XSL file,I've to handle for alignment,formating,color etc....
Once I create a tree,when I click on a node,its attributes has to be displayed on another frame.Is it possible to do this using XSL?.Can anyone help me out.Thanks in advance.
nahommAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shlomoyCommented:
using xml4j_2_0_15 (from IBM alphaworks) XML parser and using some Swing you can use the following snippet:


import com.ibm.xml.parsers.DOMParser;
import org.w3c.dom.Document;
import org.xml.sax.ErrorHandler;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
import javax.swing.*;
import ui.DOMTree;

/** SimpleTreeView builds on GetParseTreeErrors
 *  to show how to build a JTree viewer from the DOM Document reference.
 */
public class SimpleTreeView extends JFrame {

    DOMParser parser;
    Errors errors;
   
    public static void main (String args[]) {

        if (args.length > 0) {
            String filename = args[0];

            try {
                SimpleTreeView frame = new SimpleTreeView(filename) ;
                frame.addWindowListener(new java.awt.event.WindowAdapter() {
                 public void windowClosing(java.awt.event.WindowEvent e) {
                     System.exit(0);
                 }
                });
                frame.setSize(300, 400);
                frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace(System.err);
                }
        }   }

    public SimpleTreeView (String filename) {
        super("SimpleTreeView: "+filename);
        try {
            parser = new DOMParser();
            errors = new Errors();
            parser.setErrorHandler(errors);
            parser.parse(filename);
            Document document = parser.getDocument();
            getContentPane().add(new JScrollPane(new DOMTree(document)));
        } catch (Exception e) {
            e.printStackTrace(System.err);
        }
    }

    class Errors implements ErrorHandler {
        public void warning(SAXParseException ex) {
            System.err.println(ex);
        }

        public void error(SAXParseException ex) {
            System.err.println(ex);
        }

        public void fatalError(SAXParseException ex) throws SAXException {
            System.err.println(ex);
        }
    }
}



Download XML4J at http://www.alphaworks.ibm.com/tech/xml4j
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
semuelCommented:
Hello there.

Shlomo, for 100 points you're giving your program ? sucker !  :-)

Semuel.
0
shlomoyCommented:
:-)
I'm for Open-Source.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.