You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Daniel McLean <da...@mds.rmit.edu.au> on 2005/01/13 05:03:25 UTC

load-external-dtd overriden by cache-grammarFromParse

We recently observed the behaviour that if cache-grammarFromParse
feature is enabled, external DTDs will be resolved regardless of the
load-external-dtd feature setting.  This was discovered when an external
DTD could not be resolved, resulting in an error.  This came as as
surprise, although it doesn't necessarily seem wrong.  However, this
behaviour may not be intended.

We took a look at the source to find the following in DGXMLScanner.cpp:
    void DGXMLScanner::scanDocTypeDecl()
    {
        ...

        if (hasExtSubset)
        {
            if (fUseCachedGrammar)
            {
                InputSource* sysIdSrc = resolveSystemId(sysId);
                Janitor<InputSource> janSysIdSrc(sysIdSrc);
                Grammar* grammar = fGrammarResolver->getGrammar(sysIdSrc->getSystemId());
            }
        }

        if (fLoadExternalDTD || fValidate)
        {
            // And now create a reader to read this entity
            InputSource* srcUsed;
            XMLReader* reader = fReaderMgr.createReader
            (
                sysId
                , pubId
                , false
                , XMLReader::RefFrom_NonLiteral
                , XMLReader::Type_General
                , XMLReader::Source_External
                , srcUsed
                , fCalculateSrcOfs
            );

            ...
        }
    }

If this is intended behaviour, perhaps it should be documented as are
the interactions between other feature settings.  Alternatively, if the
external DTD isn't going to be used for validation, entity reference
expansion, etc, perhaps the failure to resolve an external DTD should be
ignored when loadExternalDTD is set to false or resolution skipped
entirely.

Daniel

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