Just as a sanity check, the C++ version does system id expansion and entity
resolution calls first, so if this reported action is true, its also a
semantic difference between the two.

----------------------------------------
Dean Roddey
Software Weenie
IBM Center for Java Technology - Silicon Valley
[EMAIL PROTECTED]



"Armin Pfarr" <[EMAIL PROTECTED]> on 02/18/2000 02:14:19 PM

Please respond to [EMAIL PROTECTED]

To:   <[EMAIL PROTECTED]>
cc:
Subject:  Entity-Resolver



Hi,

I'm trying to implement an entity-resolver using Xerces 1.0.1. The routine
work fine if I use public identifiers for ALL entities and redirect ALL
calls through the Entity-resolver.

Now I have a DTD, whose location is resolved through a public identifier.
That DTD includes external entities that are specified via relative
System-Identifiers. Here is a short excerpt:

<!-- Declaration of character entities -->
<!ENTITY % iso-latin1
     SYSTEM "../../Entities/ISOlat1.pen">
%iso-latin1;
<!ENTITY % iso-num
     SYSTEM "../../Entities/ISOnum.pen">
%iso-num;

These relative paths are resolved by Xerces, before the Entity-resolver is
invoked. My Entity resolver is not called like

resolveEntity(null,"../../Entities/ISOlat1.pen")

but instead like

resolveEntity(null,"file:/c:/Entities/ISOLat1.pen")

The crucial point ist, that Xerces does not construct the path above based
on the SystemId of the InputSource I constructed (I explicitelly set the
systemId with a call to setSystemId(...)), but instead based on the
System-Identifier that was stated in the document.

Any idea how to solve this problem?

Armin
P.S.
The entity-resolving works fine if I always use public identifiers. I can
then redirect to whatever source I like by using the method listed below

   protected InputSource getInputSource(String sysId) {
      InputSource src = null;
      try {
         URL url = new URL(sysId);
         src = new InputSource(url.openStream());
         src.setSystemId(sysId);
         if(debug()) log("Constructing InputStream from URL");
         return src;
      } catch (Exception e) {
        // Malformed URL or IO Exception - don't care for details
         if(debug()) log(e.getMessage());
         src = null;
      }
     // probably the specified sysId isn't a valid URI, try if it
     // is a regualar filename
      try {
         src = SAXUtils.getFileInputSource(sysId);
         if(debug()) log("Constructing InputStream from File");
         return src;
      } catch (Exception e) {
         if(debug()) log(e.getMessage());
         src = null;
      }
      return src;
   }

The problem occurs no matter if I use a correct URI or a Filename for the
mapping




Reply via email to