- From: Priscilla Walmsley <priscilla@walmsley.com>
- Date: Tue, 16 Apr 2002 14:46:23 -0400
- To: "'zahra.valaie@firstunion.com'" <zahra.valaie@firstunion.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Hi Zahra,
It looks like you did not turn validation on. To do this, add the lines:
parser.setFeature ("http://xml.org/sax/features/validation", true);
parser.setFeature ("http://apache.org/xml/features/validation/schema", true);
to your code just before the parser.parse statement.
Hope that helps!
Priscilla
-----------------------------------------------------
Priscilla Walmsley priscilla@walmsley.com
Author, Definitive XML Schema (Prentice Hall PTR)
-----------------------------------------------------
-----Original Message-----
From: zahra.valaie@firstunion.com [SMTP:zahra.valaie@firstunion.com]
Sent: Tuesday, April 16, 2002 10:36 AM
To: xmlschema-dev@w3.org
Subject: parsing a xml file against the schema
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.
I am attaching the .xml , .xsd file and .xsl file here I will add my java
code here too.
Thaks! Zahra
(See attached file: hphood_payroll.xml)(See attached file: payroll.xsl)(See
attached file: payroll.txt)(See attached file: payroll.xsd)
private static void parseXml()
{
try {
String filename = "C:\\FirsTeam\\Internet\\xml\\hphood_payroll.xml";
String outFileName = "C:\\FirsTeam\\Internet\\xml\\hphood_payroll.new.xml";
InputStream in = new FileInputStream(filename);
Writer writer = new FileWriter(outFileName);
org.apache.xerces.parsers.DOMParser parser = new org.apache.xerces.parsers.DOMParser();
parser.parse(new org.xml.sax.InputSource(in));
Document xmlDoc = parser.getDocument();
XmlUtil.printXmlNode(xmlDoc, System.out);
}
//catch(Exception e) {
// e.printStackTrace(System.out);
//}
catch(IOException e) {
System.out.println("Error in 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());
}
}
here is the java code
<< File: hphood_payroll.xml >> << File: payroll.xsl >> << File: payroll.txt >> << File: payroll.xsd >>
Received on Tuesday, 16 April 2002 14:44:42 UTC