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/11/17 13:40:32 UTC

DO NOT REPLY [Bug 14872] - can't set entity resolver

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=14872>.
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=14872

can't set entity resolver

thomas.scheffler@epost.de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |



------- Additional Comments From thomas.scheffler@epost.de  2003-11-17 12:40 -------
OK since I have the same problem I submit some code fragments here:

xml document:

<?xml version="1.0" encoding="iso-8859-1"?>
<mycoreobject
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:noNamespaceSchemaLocation="MyCoReDemoDC_LegalEntity.xsd"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:xml="http://www.w3.org/XML/1998/namespace"
  ID="MyCoReDemoDC_LegalEntity_14"
  label="Johannes Buehler">

the MyCoReDemoDC_LegalEntity.xsd should be resolved by the EntityResolver as
does the DOMParser but it's never called...

  private static String setnamespaces          =
    "http://xml.org/sax/features/namespaces";
  private static String setschemasupport       =
    "http://apache.org/xml/features/validation/schema";
  private static String setschemafullsupport   =
    "http://apache.org/xml/features/validation/schema-full-checking";

	MCREntityResolver entityResolver=new MCREntityResolver();
	SAXBuilder builderValid=new SAXBuilder("org.apache.xerces.parsers.SAXParser",true);
	builderValid.setFeature( setnamespaces,        flagnamespaces        );
	builderValid.setFeature( setschemasupport,     flagschemasupport     );
	builderValid.setFeature( setschemafullsupport, flagschemafullsupport );
	builderValid.setErrorHandler  ( this );
	builder.setEntityResolver( entityResolver );


MCREntityResolver:

  /** Implements the SAX EntityResolver interface */
  public InputSource resolveEntity( String publicId, String systemId ) 
    throws org.xml.sax.SAXException, java.io.IOException
  {
    logger.debug( "MCREntityResolver publicID = " + publicId );
    logger.debug( "MCREntityResolver systemID = " + systemId );

    if( systemId == null ) return null;


All that are code fragments of course. But I hope all the important stuff is in
there. Here is the resulting error stack trace...

     [java] INFO  MCRParserXerces SystemID: ./demo_dc_legal_01.xml
     [java] INFO  MCRParserXerces PublicID: null
     [java] WARN  demo_dc_legal_01.xml: line=8 : column=30 :
message=schema_reference.4: Failed to read schema document
'MyCoReDemoDC_LegalEntity.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>.
     [java] org.xml.sax.SAXParseException: schema_reference.4: Failed to read
schema document 'MyCoReDemoDC_LegalEntity.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>.
     [java] 	at
org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:232)
     [java] 	at
org.apache.xerces.util.ErrorHandlerWrapper.warning(ErrorHandlerWrapper.java:141)
     [java] 	at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:377)
     [java] 	at
org.apache.xerces.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:315)
     [java] 	at
org.apache.xerces.impl.xs.traversers.XSDHandler.reportSchemaWarning(XSDHandler.java:1975)
     [java] 	at
org.apache.xerces.impl.xs.traversers.XSDHandler.getSchema(XSDHandler.java:1386)
     [java] 	at
org.apache.xerces.impl.xs.traversers.XSDHandler.parseSchema(XSDHandler.java:368)
     [java] 	at
org.apache.xerces.impl.xs.XMLSchemaLoader.loadSchema(XMLSchemaLoader.java:502)
     [java] 	at
org.apache.xerces.impl.xs.XMLSchemaValidator.findSchemaGrammar(XMLSchemaValidator.java:2367)
     [java] 	at
org.apache.xerces.impl.xs.XMLSchemaValidator.handleStartElement(XMLSchemaValidator.java:1764)
     [java] 	at
org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(XMLSchemaValidator.java:697)
     [java] 	at
org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:313)
     [java] 	at
org.apache.xerces.impl.XMLNSDocumentScannerImpl$NSContentDispatcher.scanRootElementHook(XMLNSDocumentScannerImpl.java:610)
     [java] 	at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(XMLDocumentFragmentScannerImpl.java:1608)
     [java] 	at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:346)
     [java] 	at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:529)
     [java] 	at
org.apache.xerces.parsers.DTDConfiguration.parse(DTDConfiguration.java:585)
     [java] 	at org.apache.xerces.parsers.XMLParser.parse(XMLParser.java:152)
     [java] 	at
org.apache.xerces.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1142)
     [java] 	at org.jdom.input.SAXBuilder.build(SAXBuilder.java:370)

You see there is no debug output from my EntityResolver so it is not called.
What's wrong here (stacktrace of xerces 2.2.1 but error up to 2.5.0)?

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org