Uploaded image for project: 'Xerces2-J'
  1. Xerces2-J
  2. XERCESJ-1635

Report warning when we have undeclared entity reference in XML content

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 2.11.0
    • None
    • DTD
    • None

    Description

      Let's say we have an XML document like this:

      <!DOCTYPE article [
      <!ENTITY % isolat1 SYSTEM "abc.ent">
      %isolat1;
      <!ENTITY t "test" >
      ]>
      <article xmlns="http://docbook.org/ns/docbook"
          xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0">
          <info>
              <title>Article Tem&abc;plate Title</title>
      .......

      and the referenced "abc.ent" file is an empty entity file.

      if this file is parsed by Xerces with validation turned off, the reference to the non existing entity &abc; will not be reported at all.
      Usually when you apply over the XML an XSLT stylesheet the validation is turned off so in my opinion even with validation turned off at least a warning should be issued in the case in which an undeclared entity is present in the XML content because this means that the XML content is incomplete.

      The extra warning could be reported in:

      org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEntityReference()

      and:

      org.apache.xerces.impl.XML11NSDocumentScannerImpl.scanEntityReference()

      In that code the decision is something like:

                      if (fValidation) 
                          fErrorReporter.reportError( XMLMessageFormatter.XML_DOMAIN,"EntityNotDeclared", 
                                                      new Object[]{name}, XMLErrorReporter.SEVERITY_ERROR);
      

      and in my opinion it should also have an "else" branch on which to report the problem at least as a warning.

      http://www.w3.org/TR/REC-xml/#include-if-valid

      Attachments

        Activity

          People

            Unassigned Unassigned
            radu_coravu Radu Coravu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Time Tracking

                Estimated:
                Original Estimate - 3h
                3h
                Remaining:
                Remaining Estimate - 3h
                3h
                Logged:
                Time Spent - Not Specified
                Not Specified