W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > April to June 2002

Help with validating the schema

From: by way of <zahra.valaie@firstunion.com>
Date: Tue, 14 May 2002 18:32:16 -0700
Message-Id: <5.1.0.14.1.20020514183207.02aa51b8@localhost>
To: W3C XML Schema Comments list <www-xml-schema-comments@w3.org>
I am having problem parsing my xml against the schema, could you please
help me??????????????

The problem is that If I change the the data types in from int (specified
in .xsd) to a string like (abc)in the .xml file,  I don't get an
exception from the parser.

here is my Java Code:

try{
           //String urlString = "http://localhost:8080/xml/I.P.navigation.xml";
           //java.net.URL url = new java.net.URL(urlString);
           //parser.parse( new org.xml.sax.InputSource(url.openStream()));

           String filename = "C:\\FirsTeam\\Internet\\xml\\hphood_payroll.xml";
           java.lang.String xsdFileDir = "file:///C:\\FirsTeam\\Internet\\xml";
           String outFileName = 
"C:\\FirsTeam\\Internet\\xml\\hphood_payroll.new.xml";
           InputStream in = new FileInputStream(filename);

           org.apache.xerces.parsers.DOMParser parser = new 
org.apache.xerces.parsers.DOMParser();
           parser.setFeature ("http://xml.org/sax/features/validation", true);
           parser.setFeature 
("http://apache.org/xml/features/validation/schema", true);
           //parser.setProperty(
           //   "file:///C:\\FirsTeam\\Internet\\xml",
           //   new org.xml.sax.InputSource("payroll.xsd"));
           ErrorChecker errors = new ErrorChecker();
           parser.setErrorHandler(errors);
           parser.parse(new org.xml.sax.InputSource(in));
           Document xmlDoc = parser.getDocument();
           XmlUtil.printXmlNode(xmlDoc, System.out);

      }
       catch(IOException e) {
         System.out.println("Error reading File: " + e.getMessage());
      }
       catch(SAXException e) {
         System.out.println("Error in parsing: " + e.getMessage());
      }
       catch(DOMException e) {
           System.out.println("Error in parsing: " + e.getMessage());
      }


and Attached are my xml and xsd files
(See attached file: payroll.xsd)(See attached file: 
hphood_payroll.xml)  THANKS! Zahra


Received on Wednesday, 15 May 2002 15:57:51 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Sunday, 6 December 2009 18:13:00 GMT