Results 1 to 6 of 6

Thread: Spot the error!!!

  1. #1
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts

    Spot the error!!!

    Hey guys I got a bug in the following code and the error is as follows in the main function...in the line 'XMLValidator xmlv = new XMLValidator(file1, file2);' saying that it is not a statement and also another error that a semicolon is required which leads me to think that I must be doing something extremely retarded. Please help out if you guys can...I am going here....haha. Thanks in advance fellas and if you feel I forgot something relevant to mention then dont hesitate to knock me on my ass...lates.

    Code:
    package xmlvalidator;
    
    import java.io.File;
    
    /**
     *
     * @author Surya
     */
    public class XMLValidator
    {
        
        private File xml;
        private File xsd;
        
        /**
         * Creates a new instance of XMLValidator 
         */
        public XMLValidator(File xml, File xsd)
        {
            this.xml = xml;
            this.xsd = xsd;
            java.awt.EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    new ValidateGUI(this).setVisible(true);
                }
            });
        }
        
        // Returns the xml file
        public File getXmlFile()
        {
            return xml;
        }
    
        //Returns the xsd file 
        public File getXsdFile()
        {
            return xsd;
        }
        
        /**
         * @param args the command line arguments
         */
        public static void main(String[] args)
        {
            if (args.length != 2)
                System.out.println("Usage 'java XMLValidate filename.xml filename.xsd");
            else
            {
                File file1 = new File(args[0]);
                File file2 = new File(args[1]);
                
                if (file1.exists() && file2.exists())
                    XMLValidator xmlv = new XMLValidator(file1, file2);
                else
                    System.out.println("One or more of the filenames mentioned does not exist.");
            }
        }
    }

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    I see we dont have any takers...oh well...I am still staring at it...

  3. #3
    Senior Member Kezzer's Avatar
    Join Date
    Sep 2003
    Posts
    4,863
    Thanks
    12
    Thanked
    5 times in 5 posts
    Heh, the only thing i'm looking at is the thing i don't understand

    Code:
    java.awt.EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    new ValidateGUI(this).setVisible(true);
                }
            });
    I haven't seen this kind of code before so i wouldn't know if it's working or not

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    That is basically launching the Gui in a thread thats all. It is a netbeans construct and I kind of like it...in gui code threads are quite important to that things are zippy and nothing hangs while something is going on in the gui. So the above code works. Problem is with the line :
    Code:
    XMLValidator xmlv = new XMLValidator(file1, file2);
    Says that 'line 63: not a statement' and says that '; expected'. I have been trying to look at various syntactical errors I might have...if anyone has Netbeans 4.1, let me know so maybe I could email the code...it is a simple gui with a tree component on the left, a desktop panel component on the right that opens up 2 files in it, one is an xml the other is an xsd. The program is run thru the command line with an xml file and an xsd file as arguments. The program validates the xml file and also creates a tree strucutre in the gui for the model of the xml file. And the desktop panel has 2 internal frames where it opens up and displays the xml and xsd file contents for perusal. I was thinking of adding some extra functionality later on. Reason to do this si to brush up on coding, learnign Swing, learning XML and a handy little tool to validate xml files against their schemas. Thanks guys.

  5. #5
    Large Member
    Join Date
    Apr 2004
    Posts
    3,720
    Thanks
    47
    Thanked
    99 times in 64 posts
    You can't make the XMLValidator object nested in the if...else statement. I probably don't need to tell you why.
    To err is human. To really foul things up ... you need a computer.

  6. #6
    Senior Member
    Join Date
    Feb 2005
    Location
    Folsom, CA
    Posts
    221
    Thanks
    0
    Thanked
    0 times in 0 posts
    Yeah I found out my bug last night. Brain fart. I dumped that code anyway and just went into a gui all out...it works good. The gui looks good. I am now able to open an xml and an xsd file. Now i need to implement the validation code as well as a Jtree object that is based on the jdom model of the xml code. It should take me a couple more days.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Did my OC cause this?
    By myth in forum PC Hardware and Components
    Replies: 19
    Last Post: 05-04-2005, 12:36 PM
  2. A strange error Please help
    By Jambo in forum Help! Quick Relief From Tech Headaches
    Replies: 10
    Last Post: 03-04-2005, 05:09 PM
  3. Hexus.net error messages
    By daveham in forum Help! Quick Relief From Tech Headaches
    Replies: 0
    Last Post: 08-12-2004, 11:53 AM
  4. bsod error
    By MuTTy_Hc in forum Software
    Replies: 3
    Last Post: 26-09-2004, 08:50 PM
  5. Forum Speed
    By DR in forum General Discussion
    Replies: 10
    Last Post: 04-01-2004, 11:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •