HI,
To be able to validate my XML file, I need to use a set of XSD.
The first thing I did is the following:
if (myLogger.isInfoEnabled()){
myLogger.info(funcName + "Getting schema files
location.");
}
// Get the list of schema files for validation
String location = System.getProperty("schemaLocation");
File dir = new File(location);
if (dir.isDirectory()) {
// only get the .xsd files
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".xsd");
}
};
String[] filesList = dir.list(filter);
// Initialise the schemaFiles variable
this.schemaFiles = new String[filesList.length];
for (int j=0;j < filesList.length; j++) {
this.schemaFiles[j] = filesList[j];
if (myLogger.isInfoEnabled()){
myLogger.info(funcName + "Found schema file: " +
this.schemaFiles[j]);
}
}
But I got the error:
schema_reference.4: Failed to read schema document
'workItem.xsd', because 1) could not find the document; 2) the document
could not be read; 3) the root element of the document is not
<xsd:schema>.
which is not really helpfull.
As I did use not use the complete path, I have changed to:
if (myLogger.isInfoEnabled()){
myLogger.info(funcName + "Getting schema files
location.");
}
// Get the list of schema files for validation
String location = System.getProperty("schemaLocation");
File dir = new File(location);
if (dir.isDirectory()) {
// only get the .xsd files
FilenameFilter filter = new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".xsd");
}
};
String[] filesList = dir.list(filter);
// Initialise the schemaFiles variable
this.schemaFiles = new String[filesList.length];
for (int j=0;j < filesList.length; j++) {
this.schemaFiles[j] =
(location.concat(File.separator)).concat(filesList[j]);
if (myLogger.isInfoEnabled()){
myLogger.info(funcName + "Found schema file: " +
this.schemaFiles[j]);
}
}
That time I have got:
java.lang.IllegalArgumentException: When using array of Objects
as the value of SCHEMA_SOURCE property , no two Schemas should share the
same targetNamespace.
I do not understand this error too.
To set the schema location, I did:
domFactory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaS
ource", schemaLocation);
Thx in advance.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]