Class DefaultInputResolver


  • public final class DefaultInputResolver
    extends Object
    Static utility class that implements the entity (external DTD subset, external parsed entities) resolution logics.
    • Method Detail

      • resolveEntity

        public static WstxInputSource resolveEntity​(WstxInputSource parent,
                                                    URL pathCtxt,
                                                    String entityName,
                                                    String publicId,
                                                    String systemId,
                                                    XMLResolver customResolver,
                                                    ReaderConfig cfg,
                                                    int xmlVersion)
                                             throws IOException,
                                                    XMLStreamException
        Basic external resource resolver implementation; usable both with DTD and entity resolution.
        Parameters:
        parent - Input source that contains reference to be expanded.
        pathCtxt - Reference context to use for resolving path, if known. If null, reference context of the parent will be used; and if that is null (which is possible), the current working directory will be assumed.
        entityName - Name/id of the entity being expanded, if this is an entity expansion; null otherwise (for example, when resolving external subset).
        publicId - Public identifier of the resource, if known; null/empty otherwise. Default implementation just ignores the identifier.
        systemId - System identifier of the resource. Although interface allows null/empty, default implementation considers this an error.
        xmlVersion - Xml version as declared by the main parsed document. Currently only relevant for checking that XML 1.0 document does not include XML 1.1 external parsed entities. If XML_V_UNKNOWN, no checks will be done.
        customResolver - Custom resolver to use first for resolution, if any (may be null).
        cfg - Reader configuration object used by the parser that is resolving the entity
        Returns:
        Input source, if entity could be resolved; null if it could not be resolved. In latter case processor may use its own default resolution mechanism.
        Throws:
        IOException
        XMLStreamException
      • sourceFromString

        public static WstxInputSource sourceFromString​(WstxInputSource parent,
                                                       ReaderConfig cfg,
                                                       String refName,
                                                       int xmlVersion,
                                                       String refContent)
                                                throws IOException,
                                                       XMLStreamException
        We have multiple ways to look at what would it mean to get a String as the resolved result. The most straight-forward is to consider it literal replacement (with possible embedded entities), so let's use that (alternative would be to consider it to be a reference like URL -- those need to be returned as appropriate objects instead).

        Note: public to give access for unit tests that need it...

        Throws:
        IOException
        XMLStreamException