Class ValidatingStreamReader

All Implemented Interfaces:
InputConfigFlags, ParsingErrorMsgs, InputProblemReporter, StreamReaderImpl, XMLStreamConstants, XMLStreamReader, org.codehaus.stax2.DTDInfo, org.codehaus.stax2.LocationInfo, org.codehaus.stax2.typed.TypedXMLStreamReader, org.codehaus.stax2.validation.Validatable, org.codehaus.stax2.XMLStreamReader2

public class ValidatingStreamReader extends TypedStreamReader
Implementation of XMLStreamReader2 that builds on TypedStreamReader and adds full DTD-handling including DTD validation
  • Field Details

    • STAX_PROP_ENTITIES

      static final String STAX_PROP_ENTITIES
      See Also:
    • STAX_PROP_NOTATIONS

      static final String STAX_PROP_NOTATIONS
      See Also:
    • mDTD

      org.codehaus.stax2.validation.DTDValidationSchema mDTD
      Combined DTD set, constructed from parsed internal and external entities (which may have been set via override DTD functionality).
    • mAutoDtdValidator

      org.codehaus.stax2.validation.XMLValidator mAutoDtdValidator
      Validating reader keeps of automatically created DTD-based validator, since its handling may differ from that of application managed validators.
    • mDtdValidatorSet

      boolean mDtdValidatorSet
      Flag that indicates whether a DTD validator has been automatically set (as per DOCTYPE declaration or override)
    • mVldProbHandler

      protected org.codehaus.stax2.validation.ValidationProblemHandler mVldProbHandler
      Custom validation problem handler, if any.
  • Constructor Details

  • Method Details

    • createValidatingStreamReader

      public static ValidatingStreamReader createValidatingStreamReader(BranchingReaderSource input, ReaderCreator owner, ReaderConfig cfg, InputBootstrapper bs, boolean forER) throws XMLStreamException
      Factory method for constructing readers.
      Parameters:
      input - Input source used to read the XML document.
      owner - "Owner" of this reader, factory that created the reader; needed for returning updated symbol table information after parsing.
      cfg - Object that contains reader configuration info.
      bs - Bootstrapper to use, for reading xml declaration etc.
      forER - True if this reader is to be (configured to be) used by an event reader. Will cause some changes to default settings, as required by contracts Woodstox XMLEventReader implementation has (with respect to lazy parsing, short text segments etc)
      Throws:
      XMLStreamException
    • getProperty

      public Object getProperty(String name)
      Specified by:
      getProperty in interface XMLStreamReader
      Overrides:
      getProperty in class BasicStreamReader
    • getProcessedDTD

      public Object getProcessedDTD()
      Description copied from class: BasicStreamReader

      Note: DTD-handling sub-classes need to override this method.

      Specified by:
      getProcessedDTD in interface org.codehaus.stax2.DTDInfo
      Overrides:
      getProcessedDTD in class BasicStreamReader
    • getProcessedDTDSchema

      public org.codehaus.stax2.validation.DTDValidationSchema getProcessedDTDSchema()
      Description copied from class: BasicStreamReader
      Sub-class will override this method
      Specified by:
      getProcessedDTDSchema in interface org.codehaus.stax2.DTDInfo
      Overrides:
      getProcessedDTDSchema in class BasicStreamReader
    • validateAgainst

      public org.codehaus.stax2.validation.XMLValidator validateAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException
      Specified by:
      validateAgainst in interface org.codehaus.stax2.validation.Validatable
      Overrides:
      validateAgainst in class BasicStreamReader
      Throws:
      XMLStreamException
    • stopValidatingAgainst

      public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidationSchema schema) throws XMLStreamException
      Specified by:
      stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
      Overrides:
      stopValidatingAgainst in class BasicStreamReader
      Throws:
      XMLStreamException
    • stopValidatingAgainst

      public org.codehaus.stax2.validation.XMLValidator stopValidatingAgainst(org.codehaus.stax2.validation.XMLValidator validator) throws XMLStreamException
      Specified by:
      stopValidatingAgainst in interface org.codehaus.stax2.validation.Validatable
      Overrides:
      stopValidatingAgainst in class BasicStreamReader
      Throws:
      XMLStreamException
    • setValidationProblemHandler

      public org.codehaus.stax2.validation.ValidationProblemHandler setValidationProblemHandler(org.codehaus.stax2.validation.ValidationProblemHandler h)
      Specified by:
      setValidationProblemHandler in interface org.codehaus.stax2.validation.Validatable
      Overrides:
      setValidationProblemHandler in class BasicStreamReader
    • finishDTD

      protected void finishDTD(boolean copyContents) throws XMLStreamException
      This method gets called to handle remainder of DOCTYPE declaration, essentially the optional internal subset. Internal subset, if such exists, is always read, but whether its contents are added to the read buffer depend on passed-in argument.

      NOTE: Since this method overrides the default implementation, make sure you do NOT change the method signature.

      Overrides:
      finishDTD in class BasicStreamReader
      Parameters:
      copyContents - If true, will copy contents of the internal subset of DOCTYPE declaration in the text buffer (in addition to parsing it for actual use); if false, will only do parsing.
      Throws:
      XMLStreamException
    • reportValidationProblem

      public void reportValidationProblem(org.codehaus.stax2.validation.XMLValidationProblem prob) throws XMLStreamException
      If there is an error handler established, call it.
      Specified by:
      reportValidationProblem in interface InputProblemReporter
      Overrides:
      reportValidationProblem in class StreamScanner
      Throws:
      XMLStreamException
    • initValidation

      protected void initValidation() throws XMLStreamException
      Method called right before handling the root element, by the base class. This allows for some initialization and checks to be done (not including ones that need access to actual element name)
      Overrides:
      initValidation in class BasicStreamReader
      Throws:
      XMLStreamException
    • findDtdExtSubset

      private DTDSubset findDtdExtSubset(String pubId, String sysId, DTDSubset intSubset) throws XMLStreamException
      Method called by finishDTD, to locate the specified external DTD subset. Subset may be obtained from a cache, if cached copy exists and is compatible; if not, it will be read from the source identified by the public and/or system identifier passed.
      Throws:
      XMLStreamException
    • findCachedSubset

      private DTDSubset findCachedSubset(DTDId id, DTDSubset intSubset) throws XMLStreamException
      Throws:
      XMLStreamException
    • resolveExtSubsetPath

      private URI resolveExtSubsetPath(String systemId) throws IOException
      Method called to resolve path to external DTD subset, given system identifier.
      Throws:
      IOException
    • constructDtdId

      protected DTDId constructDtdId(String pubId, String sysId) throws IOException
      Throws:
      IOException
    • constructDtdId

      protected DTDId constructDtdId(URI sysId) throws IOException
      Throws:
      IOException
    • reportInvalidContent

      protected void reportInvalidContent(int evtType) throws XMLStreamException
      Method called by lower-level parsing code when invalid content (anything inside element with 'empty' content spec; text inside non-mixed element etc) is found during basic scanning. Note that actual DTD element structure problems are not reported through this method.
      Overrides:
      reportInvalidContent in class BasicStreamReader
      Parameters:
      evtType - Type of event that contained unexpected content
      Throws:
      XMLStreamException