Message: A new issue has been created in JIRA.
--------------------------------------------------------------------- View the issue: http://issues.apache.org/jira/browse/XERCESC-1204 Here is an overview of the issue: --------------------------------------------------------------------- Key: XERCESC-1204 Summary: EntityResolver not called when parse DOCTYPE in schema file Type: Bug Status: Unassigned Priority: Major Project: Xerces-C++ Components: Validating Parser (Schema) (Xerces 1.5 or up only) Versions: 2.4.0 2.5.0 Assignee: Reporter: Leo Liang Created: Thu, 29 Apr 2004 7:04 PM Updated: Thu, 29 Apr 2004 7:04 PM Environment: windows 2000, VC6 & VC.net 2003 Description: I create my own EntityResolver to redirect all access to schemas/DTDs to my local copies. It works well in many cases but fails in parsing DOCTYPE decl in xsd file. The following are schemas used in my system, vxml.xsd is used to validate voicexml document, vxml.xsd includes other schemas, like vxml-attribs.xsd. Recursly vxml-attribs.xsd imports xml.xsd. These all work as expect, my EntityResolver's resolveEntity method got call, return the local copy. But when parsing DOCTYPE in xml.xsd, my EntityResolver's resolveEntity method was not called, the parser try to make socket connection to www.w3.org but failed (my application is runned in private network). === vxml.xsd === <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.w3.org/2001/vxml" xmlns="http://www.w3.org/2001/vxml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> ...... <xsd:include schemaLocation="vxml-datatypes.xsd"/> <xsd:include schemaLocation="vxml-attribs.xsd"/> <xsd:include schemaLocation="vxml-grammar-extension.xsd"/> <xsd:include schemaLocation="vxml-synthesis-extension.xsd"/> ...... </xsd:schema> --------------------------------------------------------------------------- === vxml-attribs.xsd === <?xml version="1.0" encoding="UTF-8"?> <xsd:schema targetNamespace="http://www.w3.org/2001/vxml" xmlns="http://www.w3.org/2001/vxml" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" version="1.0"> ...... <xsd:include schemaLocation="vxml-datatypes.xsd"/> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/> ...... </xsd:schema> --------------------------------------------------------------------------- ==== xml.xsd === <?xml version='1.0'?> <!DOCTYPE xs:schema PUBLIC "-//W3C//DTD XMLSCHEMA 200102//EN" "XMLSchema.dtd" > ...... --------------------------------------------------------------------------- I've traced the code, found that the promble is in XSDDOMParser class. XSDDOMParser is derived from XercesDOMParser, XercesDOMParser has two resolveEntity method: InputSource* XercesDOMParser::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI) { if (fEntityResolver) return fEntityResolver->resolveEntity(publicId, systemId); return 0; } InputSource* XercesDOMParser::resolveEntity(XMLResourceIdentifier* resourceIdentifier) { if (fEntityResolver) return fEntityResolver->resolveEntity(resourceIdentifier->getPublicId(), resourceIdentifier->getSystemId()); if (fXMLEntityResolver) return fXMLEntityResolver->resolveEntity(resourceIdentifier); return 0; } XSDDOMParser overloads the first method, calls fUserEntityHandler's resolveEntity instead of fEntityResolver's. InputSource* XSDDOMParser::resolveEntity(const XMLCh* const publicId, const XMLCh* const systemId, const XMLCh* const baseURI) { if (fUserEntityHandler) return fUserEntityHandler->resolveEntity(publicId, systemId, baseURI); return 0; } XSDDOMParser doesn't overload the sencond one. But in ReaderMgr::createReader(), the code is: if (fEntityHandler) { XMLResourceIdentifier resourceIdentifier(XMLResourceIdentifier::ExternalEntity, expSysId.getRawBuffer(), XMLUni::fgZeroLenString, pubId, baseURI); srcToFill = fEntityHandler->resolveEntity(&resourceIdentifier); } It calls the sencond form of resolveEntity method, but XSDDOMParser doesn't overload it, so the XercesDOMParser version called. In XercesDOMParser's resolveEntity, never calls fUserEntityHandler's resolveEntity, that's it! Here is my solution: overload both resolveEntity methods in XSDDOMParser, add following codes in XSDDOMParser.cpp (also the header file). InputSource* XSDDOMParser::resolveEntity(XMLResourceIdentifier* resourceIdentifier) { if (fUserEntityHandler) return fUserEntityHandler->resolveEntity(resourceIdentifier); return 0; } --------------------------------------------------------------------- JIRA INFORMATION: This message is automatically generated by JIRA. If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
