how to change a static variable to no-static variable, the code you see is to validate an xml file, if I change this line
private static final String XML = "xml/laPartieWord.xml";to
String XML = "xml/laPartieWord.xml";I m getting error " Cannot make a static reference to the non-static field XML
"
{
import java.io.*;
import javax.xml.XMLConstants;
import javax.xml.transform.sax.SAXSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
public class ValidationWXS {
private static final String SCHEMA = "xml/laPartieWord.xsd";
String XML = "xml/laPartieWord.xml";
public static void main(String[] args) throws IOException, SAXException {
SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
Schema xsd = sf.newSchema(new File(SCHEMA));
Validator validator = xsd.newValidator();
SAXSource src = new SAXSource(new InputSource(XML));
try {
validator.validate(src);
System.out.println("Le document '" + XML + "' est VALIDE!!!");
} catch (SAXException e) {
System.out.println("*** Le document '" + XML + "' n'est pas valide ***");
e.printStackTrace();
}
}
}
}