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 Scott Greenough <sc...@haht.com> on 2000/07/24 15:59:28 UTC

Problems with the EntityResolver

I'm trying to implement the EntityResolver interface using the Xerces-J
1_1_2 version and I'm having a problem.

If I parse a document that has an existing DOCTYPE and replace it with my
own, everything works hunky-dory. However, the moment I try this with a
document that doesn't have a doctype definition, it will not use my
EntityResolver.

Any clues?

Thanks,
Scott Greenough
HAHT Commerce, Inc.

Re: Problems with the EntityResolver

Posted by Andy Clark <an...@apache.org>.
Scott Greenough wrote:
> If I parse a document that has an existing DOCTYPE and replace it 
> with my own, everything works hunky-dory. However, the moment I try 
> this with a document that doesn't have a doctype definition, it will 
> not use my EntityResolver.

Are you trying to use the entity resolver in order to resolve the
document itself?

The documentation for the SAX EntityResolver interface states that
it is used for external entities and makes no reference of the
document entity. And the JavaDoc for the resolveEntity method
states the following:

  "The Parser will call this method before opening any external
   entity except the top-level document entity"
          ^^^^^^

-- 
Andy Clark * IBM, JTC - Silicon Valley * andyc@apache.org

strange entity declaration parsing

Posted by Neil de Hoog <ne...@lunatech.com>.
I get a strange parsing result from the document shown below.

The first ulink gives me:
  prefix      = ulink url="http
  localpart   = ://sit
  rawname     = ulink
  uri         =
null                                                                   

The second ulink gives me:
  prefix      = null
  localpart   = ulink
  rawname     = ulink
  uri         =
null                                                                   

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article SYSTEM "/opt/xml/simple-docbook/sdocbook.dtd" [
    <!ENTITY neil '<ulink url="http://site.neil/">here</ulink>'>
]>
<article>
  <para>And &neil; we will find everything we always wanted to
have.</para>
  <para>And <ulink url="http://site.neil/">here</ulink> we will find
everything we always wanted to have.</para>
  &testpara;
</article> 

I get the impression that something is misbehaving while parsing entity
declarations. Possibly Stringreader which does something when it meets a
':'.

-- 

Neil de Hoog

neil@lunatech.com
neil@v2.nl

bug in MixedContentModel.whatCanGoHere?

Posted by Neil de Hoog <ne...@lunatech.com>.
Sorry if this is old stuff. In the MixedContentModel.whatCanGoHere
method I read:

        //
        //  If the fully valid parameter is set, then whether any
child can
        //  go here is dependent upon the content model having been
valid all
        //  the way to the end. If its not, nothing we put here is
going to
        //  make it happy. If it was ok, then nothing we put here is
ever going
        //  make it bad.
        //
        //  So set up a boolean that can be used to set every possible
child's
        //  insertable status below.
        //
        boolean bStatus = true;
        if (fullyValid && (failedIndex < info.childCount))
            bStatus = false;

Why, if (failedIndex == -1) which means the current content is ok,
should bStatus be false? Doesn't 

	if (fullyValid && (failedIndex != -1))

do a better job? Or am I wrong in assuming the results array in the
InsertableElementsInfo indicates whether a certain element can be
inserted or not?

Neil de Hoog