You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by bu...@apache.org on 2002/11/22 19:27:29 UTC
DO NOT REPLY [Bug 14775] New: -
SAX parser not able to locate XML schema(?)
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14775>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=14775
SAX parser not able to locate XML schema(?)
Summary: SAX parser not able to locate XML schema(?)
Product: Xerces2-J
Version: 2.2.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Critical
Priority: Other
Component: SAX
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: sridharranganathan@hotmail.com
Trying to read the personal-schema.xml document(that comes with xerces) using
the following code, but am running into the following error:
"org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of
element 'personnel'."
Are there any other properties, which I need to set.
Here is the core code, which creates a parser and then parses -
public XMLImportFileReader (String fileName, boolean isValidating,
IXMLProcessor theProcessor) throws Exception {
// Configure and set up the XML reader/parser.
SAXParserFactory spf;
// Get a parser from the Parser Factory
try {
spf = SAXParserFactory.newInstance();
} catch ( FactoryConfigurationError fce ) {
cat.error("Id 1, Error getting new instance of Parser factory");
throw fce;
}
// Configure the factory to produce parsers either validating
// or non validating parsers.
spf.setValidating(isValidating);
SAXParser saxParser;
// Create a JAXP SAXParser
try {
saxParser = spf.newSAXParser();
} catch (ParserConfigurationException pce){
cat.error("Id 2, Error creating a new SAX Parser");
throw pce;
}
// Get the encapsulated SAX XMLReader
_xmlReader = saxParser.getXMLReader();
_xmlReader.setFeature("http://xml.org/sax/features/validation", true);
_xmlReader.setFeature
("http://apache.org/xml/features/validation/schema", true);
String id = "http://apache.org/xml/properties/schema/external-
noNamespaceSchemaLocation";
String value = "personal.xsd";
_xmlReader.setProperty(id, value);
// Set the ContentHandler of the XMLReader
_xmlReader.setContentHandler(this);
// Set an ErrorHndler before parsing
_xmlReader.setErrorHandler(new ImportErrors(this));
_processor = theProcessor;
}
/**
* Parse the input document.
*/
public void load(String fileName) throws Exception {
try {
InputSource input = new InputSource(getSourceUrl(fileName));
_xmlReader.parse(input);
} catch (FileNotFoundException fnfe) {
throw fnfe;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org