Java 8 EntityResolver - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 EntityResolver class.

This code example shows how to use the following methods:resolveEntity
		if (systemId != null) {
			if (systemId.endsWith(DTD_SUFFIX)) {
				return this.dtdResolver.resolveEntity(publicId, systemId);
			} 
			else if (systemId.endsWith(XSD_SUFFIX)) {
				return this.schemaResolver.resolveEntity(publicId, systemId);
			} 
		} 
		return null; 
	} 
 
 
	@Override 
	public String toString() {
		return "EntityResolver delegating " + XSD_SUFFIX + " to " + this.schemaResolver +
				" and " + DTD_SUFFIX + " to " + this.dtdResolver;
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:resolveEntity
                                                           systemId );
            if ( inputSource != null ) {
                return inputSource;
            } 
            if ( this.entityResolver != null ) {
                return this.entityResolver.resolveEntity( publicId,
                                                          systemId );
            } 
        } catch ( final IOException ioe ) {
        } 
        return null; 
    } 
 
    public void startPrefixMapping(final String prefix,
                                   final String uri) throws SAXException {
        super.startPrefixMapping( prefix,
                                  uri );
        this.namespaces.put( prefix,
                             uri );
    } 
5
CodeRank
This code example shows how to use the following methods:resolveEntity
 
        Schema schema = schemas.findSchema(systemId);
 
        if (schema == null) {
            if (defaultEntityResolver != null) {
                return defaultEntityResolver.resolveEntity(publicId, systemId);
            } else { 
                return null; 
            } 
        } 
 
        log.debug("Found XML schema for systemId {}: {}", systemId, schema);
 
        InputSource inputSource = new InputSource(schema.getInputStream());
 
        inputSource.setPublicId(publicId);
        inputSource.setSystemId(systemId);
 
        return inputSource;
    } 
5
CodeRank
This code example shows how to use the following methods:resolveEntity
 
    /** {@inheritDoc} */ 
    public InputSource resolveEntity(String publicId, String systemId)
            throws SAXException, IOException {
        if (entityResolver != null) {
            return entityResolver.resolveEntity(publicId, systemId);
        } else { 
            return null; 
        } 
    } 
 
    // ==== DTDHandler 
 
    /** {@inheritDoc} */ 
    public void notationDecl(String name, String publicId, String systemId) throws SAXException {
        if (dtdHandler != null) {
            dtdHandler.notationDecl(name, publicId, systemId);
        } 
    } 
 
3
CodeRank
This code example shows how to use the following methods:resolveEntity
String url = XMLJ.getAbsoluteURI(base, systemId);
    InputStream in = null;
    if (entityResolver != null)
      { 
        InputSource source = entityResolver.resolveEntity(publicId, url);
        if (source != null)
          { 
            in = XMLJ.getInputStream(source);
          } 
      } 
    if (in == null)
      { 
        in  = XMLJ.getInputStream(new URL(url));
      } 
    return in;
  } 
 
  private void warning(String message,
                       int lineNumber,
3
CodeRank
This code example shows how to use the following methods:resolveEntity
          throws SAXException, IOException
  { 
 
    if (m_entityResolver != null)
    { 
      return m_entityResolver.resolveEntity(publicId, systemId);
    } 
    else 
    { 
      return null; 
    } 
  } 
 
  //////////////////////////////////////////////////////////////////// 
  // Implementation of org.xml.sax.DTDHandler. 
  //////////////////////////////////////////////////////////////////// 
 
  /** 
   * Filter a notation declaration event. 
   * 
3
CodeRank
This code example shows how to use the following methods:resolveEntity
                    return null; 
                } 
            } 
            //Debug.logInfo("[UtilXml.LocalResolver.resolveEntity] local resolve failed for DTD with publicId [" + 
            //        publicId + "] and the dtd file is [" + dtd + "], trying defaultResolver", module); 
            return defaultResolver.resolveEntity(publicId, systemId);
        } 
 
        /** 
         * Returns the boolean value to inform id DTD was found in the XML file or not 
         * @return boolean - true if DTD was found in XML 
         */ 
        public boolean hasDTD() { 
            return hasDTD;
        } 
    } 
 
 
    /** Local error handler for entity resolver to DocumentBuilder parser. 
     * Error is printed to output just if DTD was detected in the XML file. 
2
CodeRank
This code example shows how to use the following methods:resolveEntity
          throws SAXException, IOException 
  { 
 
    if (m_entityResolver != null)
    { 
      return m_entityResolver.resolveEntity(publicId, systemId);
    } 
    else 
    { 
      return null; 
    } 
  } 
 
  //////////////////////////////////////////////////////////////////// 
  // Implementation of org.xml.sax.DTDHandler. 
  //////////////////////////////////////////////////////////////////// 
 
  /** 
   * Filter a notation declaration event. 
   * 
3
CodeRank
This code example shows how to use the following methods:resolveEntity
                System.logI("Could not resolve '" + systemId + "' relative to"
                        + " '" + this.systemId + "' at " + locator, e);
            } 
        } 
 
        InputSource inputSource = entityResolver.resolveEntity(
                publicId, systemId);
        if (inputSource == null) {
            /* 
             * The spec. actually says that we should try to treat systemId 
             * as a URL and download and parse its contents here, but an 
             * entity resolver can easily accomplish the same by returning 
             * new InputSource(systemId). 
             * 
             * Downloading external entities by default would result in several 
             * unwanted DTD downloads, not to mention pose a security risk 
             * when parsing untrusted XML -- see for example 
             * http://archive.cert.uni-stuttgart.de/bugtraq/2002/10/msg00421.html -- 
             * so we just do nothing instead. This also enables the user to 
             * opt out of entity parsing when using 
3
CodeRank
This code example shows how to use the following methods:resolveEntity
      try { 
         URL url = new URL(xmlReader.getSystemID());
         url = new URL(url, systemID);
 
         if (this.saxEntityResolver != null) {
            InputSource source
            = this.saxEntityResolver
            .resolveEntity(publicID, url.toString());
 
            if (source != null) {
               Reader reader = source.getCharacterStream();
 
               if (reader != null) {
                  return reader;
               } 
 
               InputStream stream = source.getByteStream();
 
               if (stream == null) {
                  publicID = source.getPublicId();
3
CodeRank
See Code Examples for Java 8 EntityResolver Methods: