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 2003/02/25 18:42:41 UTC
DO NOT REPLY [Bug 17382] New: -
Setting external-schemaLocation causes java.lang.ClassCastException
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=17382>.
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=17382
Setting external-schemaLocation causes java.lang.ClassCastException
Summary: Setting external-schemaLocation causes
java.lang.ClassCastException
Product: Xerces2-J
Version: 2.3.0
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Blocker
Priority: Other
Component: DOM
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: bo.esbech@memobase.dk
I have an application that uses Xerces for XML Schema validation. I previously
used Xerces-2.0.1 but had dissided to upgrade to Xerces-2.3.0. The application
run without any problem with Xerces-2.0.1 but fails with an
java.lang.ClassCastException when running with Xerces-2.3.0. I have isolated
the problem and written a small program that illustrates the problem. The
program is shown below:
--- xerces_test.java ---
import java.io.*;
import org.xml.sax.SAXException;
import org.xml.sax.*;
import org.w3c.dom.Document;
import org.w3c.dom.DocumentType;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.w3c.dom.Element;
import org.w3c.dom.Text;
import org.apache.xerces.parsers.DOMParser;
import java.util.*;
import java.security.*;
class SOAPErrorHandler implements ErrorHandler {
private String m_sErrorText = "";
private boolean m_bSchemaValid = true;
private void catchError(SAXParseException exception) {
m_sErrorText += exception.getMessage();
m_bSchemaValid = false;
}
public void error(SAXParseException exception){catchError(exception);}
public void fatalError(SAXParseException exception){catchError
(exception);}
public void warning(SAXParseException exception){catchError(exception);}
public boolean isSchemaValid() { return( m_bSchemaValid ); }
public String getErrorText() { return( m_sErrorText ); }
}
public class xerces_test {
public static void main( String args[] ) throws Exception{
System.out.println( "Tester stated..." );
DOMParser parser = new DOMParser();
parser.setFeature("http://xml.org/sax/features/namespaces",
true);
parser.setFeature("http://xml.org/sax/features/validation",
true);
parser.setFeature
("http://apache.org/xml/features/validation/schema", true);
// Make sure to validate SOAP elements against XML Shchema.
String schemaLocation
= "http://schemas.xmlsoap.org/soap/envelope/ http://intranet/temp/envelope.xsd";
parser.setProperty
("http://apache.org/xml/properties/schema/external-schemaLocation",
schemaLocation);
SOAPErrorHandler err = new SOAPErrorHandler();
parser.setErrorHandler(err);
System.out.println( "Beginning to parse..." );
// Parse posted XML and check weather XML comforms with SOAP
specification.
try {
parser.parse( args[0]);
}catch( SAXParseException e) {
System.out.println( "Error parsing request. Parser
returned: " + err.getErrorText() );
return;
}
if( !err.isSchemaValid() ) {
System.out.println( "XML document does not conform with
SOAP and/or xsql specifications. Parser returned: " + err.getErrorText() );
return;
}
System.out.println( "Source valid..." );
}
}
--- END OF FILE ---
When running with Xerces-2.3.0 i get the folling exception.
Tester stated...
Beginning to parse...
Exception in thread "main" java.lang.ClassCastException:
org.apache.xerces.impl.dv.xs.ListDV$ListData
at org.apache.xerces.impl.xs.XMLSchemaLoader.processExternalHints
(Unknown Source)
at org.apache.xerces.impl.xs.XMLSchemaValidator.reset(Unknown Source)
at org.apache.xerces.parsers.BasicParserConfiguration.reset(Unknown
Source)
at org.apache.xerces.parsers.DTDConfiguration.reset(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
at xerces_test.main(xerces_test.java:54)
Line 54 in xerces_test.java is "parser.parse( args[0]);".
The program runs without problems with Xerces-2.2.1 as well.
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org