Java Code Examples for org.xml.sax.EntityResolver#resolveEntity()

The following examples show how to use org.xml.sax.EntityResolver#resolveEntity() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SAXParseable.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 2
Source File: MicroSAXHandler.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public InputSource resolveEntity (@Nullable final String sName,
                                  @Nullable final String sPublicId,
                                  @Nullable final String sBaseURI,
                                  @Nonnull final String sSystemId) throws SAXException, IOException
{
  _updatePosition ("resolveEntity2");
  final EntityResolver2 aER2 = m_aEntityResolver2;
  if (aER2 != null)
    return aER2.resolveEntity (sName, sPublicId, sBaseURI, sSystemId);

  final EntityResolver aER = m_aEntityResolver;
  if (aER != null)
    return aER.resolveEntity (sPublicId, sSystemId);

  if (LOGGER.isInfoEnabled ())
    LOGGER.info ("Need to resolve entity with name '" +
                 sName +
                 "', public ID '" +
                 sPublicId +
                 "' base URI '" +
                 sBaseURI +
                 "' and system ID '" +
                 sSystemId +
                 "'");
  return null;
}
 
Example 3
Source File: MicroSAXHandler.java    From ph-commons with Apache License 2.0 5 votes vote down vote up
@Nullable
public InputSource resolveEntity (final String sPublicId, final String sSystemId) throws IOException, SAXException
{
  _updatePosition ("resolveEntity");
  final EntityResolver aER = m_aEntityResolver;
  if (aER != null)
    return aER.resolveEntity (sPublicId, sSystemId);

  // If using XHTML this should be replaced by using the LocalEntityResolver
  // instead
  if (sPublicId == null)
  {
    if (LOGGER.isInfoEnabled ())
      LOGGER.info ("Need to resolve entity with system ID '" + sSystemId + "'");
  }
  else
    if (sSystemId == null)
    {
      if (LOGGER.isInfoEnabled ())
        LOGGER.info ("Need to resolve entity with public ID '" + sPublicId + "'");
    }
    else
    {
      if (LOGGER.isInfoEnabled ())
        LOGGER.info ("Need to resolve entity with public ID '" + sPublicId + "' and system ID '" + sSystemId + "'");
    }
  return null;
}
 
Example 4
Source File: NGCCRuntimeEx.java    From jolie with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Resolves relative URI found in the document.
 *
 * @param namespaceURI
 *      passed to the entity resolver.
 * @param relativeUri
 *      value of the schemaLocation attribute. Can be null.
 *
 * @return
 *      non-null if {@link EntityResolver} returned an {@link InputSource},
 *      or if the relativeUri parameter seems to be pointing to something.
 *      Otherwise it returns null, in which case import/include should be abandoned.
 */
private InputSource resolveRelativeURL( String namespaceURI, String relativeUri ) throws SAXException {
    try {
        String baseUri = getLocator().getSystemId();
        if(baseUri==null)
            // if the base URI is not available, the document system ID is
            // better than nothing.
            baseUri=documentSystemId;

        String systemId = null;
        if(relativeUri!=null)
            systemId = Uri.resolve(baseUri,relativeUri);

        EntityResolver er = parser.getEntityResolver();
        if(er!=null) {
            InputSource is = er.resolveEntity(namespaceURI,systemId);
            if(is!=null)
                return is;
        }

        if(systemId!=null)
            return new InputSource(systemId);
        else
            return null;
    } catch (IOException e) {
        SAXParseException se = new SAXParseException(e.getMessage(),getLocator(),e);
        parser.errorHandler.error(se);
        return null;
    }
}
 
Example 5
Source File: SAXParseable.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 6
Source File: ExternalEntity.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 7
Source File: SAXParseable.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 8
Source File: ExternalEntity.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 9
Source File: SAXParseable.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 10
Source File: ExternalEntity.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 11
Source File: ExternalEntity.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 12
Source File: ExternalEntity.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 13
Source File: SAXParseable.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 14
Source File: ExternalEntity.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 15
Source File: RuntimeCatalogModel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public ModelSource getModelSource(URI locationURI,
        ModelSource modelSourceOfSourceDocument) throws CatalogModelException {
    InputStream inputStream = null;
    try {
        UserCatalog cat = UserCatalog.getDefault();
        // mainly for unit tests
        if (cat == null) {
            return null;
        }
        EntityResolver resolver = cat.getEntityResolver();
        InputSource src = resolver.resolveEntity(null, locationURI.toString());
        if(src != null) {
            inputStream = new URL(src.getSystemId()).openStream();
        } else {
            javax.xml.transform.Source isrc = ((javax.xml.transform.URIResolver)resolver).
                    resolve(locationURI.toString(), null);
            if(isrc != null)
                inputStream = new URL(isrc.getSystemId()).openStream();
        }
        if(inputStream != null)
            return createModelSource(inputStream);
    } catch (Exception ex) {
        throw new CatalogModelException(ex);
    }
    
    return null;
}
 
Example 16
Source File: SAXParseable.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 17
Source File: CompoundEntityResolver.java    From rice with Educational Community License v2.0 5 votes vote down vote up
/**
 * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)
 */
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException {
    LOG.debug("resolveEntity: " + publicId + " " + systemId);
    for (EntityResolver resolver: resolvers) {
        LOG.debug("Invoking entity resolver: " + resolver);
        InputSource source = resolver.resolveEntity(publicId, systemId);
        if (source != null) {
            LOG.debug("source != null: " + source);
            return source;
        }
    }
    return null;
}
 
Example 18
Source File: SAXParseable.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}
 
Example 19
Source File: ExternalEntity.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
public InputSource getInputSource(EntityResolver r)
        throws IOException, SAXException {

    InputSource retval;

    retval = r.resolveEntity(publicId, systemId);
    // SAX sez if null is returned, use the URI directly
    if (retval == null)
        retval = Resolver.createInputSource(new URL(systemId), false);
    return retval;
}
 
Example 20
Source File: SAXParseable.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
private static InputSource makeInputSource(XMLReader xr, String systemId) throws IOException, SAXException {
  EntityResolver er = xr.getEntityResolver();
  if (er != null) {
    InputSource inputSource = er.resolveEntity(null, systemId);
    if (inputSource != null)
  return inputSource;
  }
  return new InputSource(systemId);
}