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 Cirip Tomas <to...@theIMO.com> on 2002/02/15 21:39:38 UTC

Still have EntityResolver problem

Hi all,

I still have a problem with entity resolver:

here is a fraction of XML document

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root SYSTEM "test.dtd">
<root>

anyway I get systemId="d:\tc\test.dtd" in resolveEntity method of my
EntityResolver.

when I specify

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root SYSTEM "xml/test.dtd">
<root>

I get systemId="d:\tc\xml\test.dtd"

Why? Where is it getting "d:\tc\" from? I parse XML Document using following
code

      InputSource inputSource = new InputSource(new
java.io.StringReader(getText()));
	parser.setEntityResolver(new MyEntityResolver());	
      parser.parse(inputSource);

Thanks

Tomas

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


Re: Still have EntityResolver problem

Posted by Andy Clark <an...@apache.org>.
Cirip Tomas wrote:
> Why? Where is it getting "d:\tc\" from? I parse XML Document using following
> code

Without a base systemId to work with, the parser tries to locate
the DTD by using the current working directory of the application
to expand the relative systemId. To avoid this and use your own
base systemId, remember to set the systemId of your input source.

>       InputSource inputSource = new InputSource(new
> java.io.StringReader(getText()));
>         parser.setEntityResolver(new MyEntityResolver());
>       parser.parse(inputSource);

Add a line of code after you create the input source to set a
systemId that it should use to expand relative systemIds. For
example:

  InputSource inputSource = new InputSource(new StringReader(TEXT));
  inputSource.setSystemId("http://www.example.com/path/document.xml");

Then, when the parser sees the relative systemId "test.dtd" 
in your document, the expanded systemId passed to your entity 
resolver will be "http://www.example.com/path/test.dtd".

-- 
Andy Clark * andyc@apache.org

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


Re: Still have EntityResolver problem

Posted by John Utz <ut...@singingfish.com>.
i assume that you are running your program from the directory d:\tc,
correct?

On Fri, 15 Feb 2002, Cirip Tomas wrote:

> Hi all,
> 
> I still have a problem with entity resolver:
> 
> here is a fraction of XML document
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE root SYSTEM "test.dtd">
> <root>
> 
> anyway I get systemId="d:\tc\test.dtd" in resolveEntity method of my
> EntityResolver.
> 
> when I specify
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE root SYSTEM "xml/test.dtd">
> <root>
> 
> I get systemId="d:\tc\xml\test.dtd"
> 
> Why? Where is it getting "d:\tc\" from? I parse XML Document using following
> code
> 
>       InputSource inputSource = new InputSource(new
> java.io.StringReader(getText()));
> 	parser.setEntityResolver(new MyEntityResolver());	
>       parser.parse(inputSource);
> 
> Thanks
> 
> Tomas
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> 


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