http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2566 *** shadow/2566 Wed Jul 11 00:59:09 2001 --- shadow/2566.tmp.6331 Wed Jul 11 00:59:09 2001 *************** *** 0 **** --- 1,98 ---- + +============================================================================+ + | Validation of XML document always failed with namespace declaration | + +----------------------------------------------------------------------------+ + | Bug #: 2566 Product: Xerces2-J | + | Status: NEW Version: 2.0.0 [alpha] | + | Resolution: Platform: PC | + | Severity: Major OS/Version: Windows NT/2K | + | Priority: Other Component: JAXP | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + I wrote a testing Java program by using JAXP DOM interface, the program is + running fine until I turned on Validation by calling factory.setValidation + (true). It always failed if the XML file parsed has Namespace decaration on the + element attributes. The following is my test program: + + import java.io.*; + import javax.xml.parsers.*; + import org.xml.sax.*; + import org.w3c.dom.*; + + public class LoadXMLByURI + { + public static void main(String[] args) + { + try + { + if (args.length == 0) + System.out.println("using 'java LoadXMLByURI uriString'"); + + DocumentBuilder builder; + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + factory.setNamespaceAware(true); + factory.setValidating(true); + builder = factory.newDocumentBuilder(); + builder.setErrorHandler(new SAXErrorHandler()); + InputSource in = new InputSource(args[0]); + Document doc = builder.parse(in); + if (doc == null) { + System.out.println("document is null"); + return; + } + Element root = doc.getDocumentElement(); + String s = root.getLocalName(); + System.out.println("Local name = " + s); + } + catch (org.xml.sax.SAXException ex) + { + ex.printStackTrace(); + } + catch (javax.xml.parsers.ParserConfigurationException ex) + { + ex.printStackTrace(); + } + catch (java.io.IOException ex) + { + ex.printStackTrace(); + } + + } + } + + I am running this program by using following: + + java LoadXMLByURI http://schemas.xmlsoap.org/soap/envelope/ + + The following is the part of the error I got: + + org.xml.sax.SAXParseException: General Schema Error: Grammar with uri 2: http:// + www.w3.org/1999/XMLSchema , can not be found. + at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1196 + ) + at org.apache.xerces.validators.common.XMLValidator.reportRecoverableXML + Error(XMLValidator.java:1727) + at org.apache.xerces.validators.common.XMLValidator.validateElementAndAt + tributes(XMLValidator.java:3108) + at org.apache.xerces.validators.common.XMLValidator.callStartElement(XML + Validator.java:1149) + at org.apache.xerces.framework.XMLDocumentScanner.scanElement(XMLDocumen + tScanner.java:1862) + at org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.disp + atch(XMLDocumentScanner.java:1005) + at org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentS + canner.java:381) + at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1081) + at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(DocumentBuilderImpl. + java:195) + at LoadXMLByURI.main(LoadXMLByURI.java:26) + org.xml.sax.SAXParseException: Element type "schema" must be declared. + at org.apache.xerces.framework.XMLParser.reportError(XMLParser.java:1196 + ) + + I am using xerces.jar version of 1.4.1 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
