Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to modify a static value to variable value

843834Mar 3 2008 — edited Mar 3 2008
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();
}
}

}

}
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 31 2008
Added on Mar 3 2008
2 comments
302 views