jaxp 1.3 validate xml with noNameSpaceSchemaLocation?

E

Elhanan

hi .. i have the following:

File f=new File(xmlFile);
Schema s=getScehma(xsdFile);
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
SAXParser saxParser = spf.newSAXParser();
spf.setValidating(true);

// spf.setFeature("http://xml.org/sax/features/validation",
true);
//
spf.setFeature("http://apache.org/xml/features/validation/schema",
true);


saxParser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");

saxParser.parse(f, new DefaultHandler());

in xerces this works without specify an external schema, but here it
reads it ok (even thought it's not a valid file).

what i'm aiming for is that to make an xml config file that every xml
parser will fail, if it won't comply to the xsd..
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top