How to change the property a SAXBuilder object used with JDOM
843834Jun 11 2008 — edited Jun 12 2008Hi
I am validating xml using JDOM.
for that I use following code.
String schema1="http://www.w3.org/2001/06/soap-envelope";
String schema2="http://www.w3.org/2003/05/soap-envelope";
saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser",true);
/* I tried < saxBuilder = new SAXBuilder(); > also */
saxBuilder.setValidation(true);
saxBuilder.setFeature("http://apache.org/xml/features/validation/schema", true);
saxBuilder.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage", "http://www.w3.org/2001/XMLSchema");
saxBuilder.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",schema1);
Document document = saxBuilder.build("C:\\request.xml"));
Till now it worked fine. I was able to get Document object.
Now I want to change the schema from schema1 to schema2 on the same SAXBuilder object to validate some other xml. So I tried
saxBuilder.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",schema2); //never works
But above line of code never works.
The first schema(schema1 ) is used even after this line of code.
Please advice me a way to reset the saxBuilder and change its property.
Regards
Rohit