Code example for InputSource

Methods: getCharacterStream, getEncoding, getPublicId, getSystemId

0
 
        String encoding = pickEncoding(inputSource);
        int pointer = createEntityParser(this.pointer, context);
        try { 
            EntityParser entityParser = new EntityParser(encoding, xmlReader,
                    pointer, inputSource.getPublicId(),
                    inputSource.getSystemId());
 
            parseExternalEntity(entityParser, inputSource);
        } finally { 
            releaseParser(pointer);
        } 
    } 
 
    /** 
     * Picks an encoding for an external entity. Defaults to UTF-8. 
     */ 
    private String pickEncoding(InputSource inputSource) {
        Reader reader = inputSource.getCharacterStream();
        if (reader != null) {
            return CHARACTER_ENCODING;
        } 
 
        String encoding = inputSource.getEncoding();
        return encoding == null ? DEFAULT_ENCODING : encoding;
    } 
 
    /** 
     * Parses the the external entity provided by the input source.