• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML file validation with the XSD

 
Ranch Hand
Posts: 77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I am using the following code for validation of a xml file with its corresponding XML schema. The validation is successful even when there is a non-compliance with the schema. For eg., for an element which is declared as
minOccurs and maxOccurs to be "1" (mandatory attribute), and removing this element in the XML document, doesnt show that the file is invalid. But any incorrect semantics are being found through this code (like missing "<"http://apache.org/xml/features/validation/schema", true);
parser.setProperty(
"http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation",
"Latest_DWS.xsd");
parser.parse("promotionPlanChangeMA_ALL.xml");
System.out.print("Successful");
}
catch (Exception e)
{
System.out.print("Problem parsing the file.");
e.printStackTrace();
}
}
}

Many thanks in advance!!
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic