You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Francis Upton <fr...@nogoop.com> on 2003/11/06 03:37:24 UTC

problem resolving SYSTEM entity to current directory

Using Xerces-J version 2.5.0, I am running into a problem where a relative 
SYSTEM entity reference seems to be attempted to be resolved to the current 
directory (and fails), rather than to the location of the document (as 
specified in the XML specification).

I have the following XML File:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE Guideline SYSTEM 'testresolve.dtd'>
<x/>

In the same directory is the file 'testresolve.dtd'.

 From a different directory, I run this code:

import java.io.*;

import org.xml.sax.*;
import org.xml.sax.helpers.*;

public class test
{

     protected static final String DEFAULT_PARSER_NAME =
         "org.apache.xerces.parsers.SAXParser";


     public static void main(String[] args)
     {
         try
         {
             InputSource is =
                 new InputSource
                 (new BufferedInputStream
                  (new FileInputStream("../testresolve.xml")));

             XMLReader xmlReader = XMLReaderFactory.
                 createXMLReader(DEFAULT_PARSER_NAME);
             xmlReader.parse(is);
         }
         catch (Exception ex)
         {
             ex.printStackTrace();
         }
     }

}


And when I run it, I get this result:

/temp/trans/x> java test
java.io.FileNotFoundException: c:\temp\trans\x\testresolve.dtd (The system 
cannot find the file spec
ified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(FileInputStream.java:106)
         at java.io.FileInputStream.<init>(FileInputStream.java:66)
         at 
sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:69)
         at 
sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:156)
         at java.net.URL.openStream(URL.java:913)
         at 
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.startEntity(Unknown Source)
         at org.apache.xerces.impl.XMLEntityManager.startDTDEntity(Unknown 
Source)
         at org.apache.xerces.impl.XMLDTDScannerImpl.setInputSource(Unknown 
Source)
         at 
org.apache.xerces.impl.XMLDocumentScannerImpl$DTDDispatcher.dispatch(Unknown 
Source)
         at 
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown 
Source)
         at org.apache.xerces.parsers.XML11Configuration.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.AbstractSAXParser.parse(Unknown Source)
         at test.main(test.java:25)

However, if I copy the file 'testresolve.dtd' to the current directory, I 
get this result (which is what I expect):

/temp/trans/x> cp ../testresolve.dtd .
/temp/trans/x> java test
/temp/trans/x>

Am I doing something wrong, or is this a bug?

Could this be related (or the same as) bug 11441?

Thanks,

Francis


Francis Upton
nogoop software
ActiveX/COM Inspector
.NET Component Inspector
Java HTTP Client
www.nogoop.com


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