private void parseEntityDecl ( ) throws Exception { boolean peFlag = false ; int flags = 0 ; // Check for a parameter entity. expandPE = false ; requireWhitespace ( ) ; if ( tryRead ( ' ' ) ) { peFlag = true ; requireWhitespace ( ) ; } expandPE = true ; // Read the entity name, and prepend // '%' if necessary. String name = readNmtoken ( true ) ; // NE08 if ( name . indexOf ( ' ' ) >= 0 ) { fatal ( "Illegal character(':') in entity name " , name , null ) ; } if ( peFlag ) { name = "%" + name ; } // Read the entity value. requireWhitespace ( ) ; char c = readCh ( ) ; unread ( c ) ; if ( ( c == ' ' ) || ( c == ' ' ) ) { // Internal entity ... replacement text has expanded refs // to characters and PEs, but not to general entities String value = readLiteral ( flags ) ; setInternalEntity ( name , value ) ; } else { // Read the external IDs ExternalIdentifiers ids = readExternalIds ( false , false ) ; // Check for NDATA declaration. boolean white = tryWhitespace ( ) ; if ( ! peFlag && tryRead ( "NDATA" ) ) { if ( ! white ) { fatal ( "whitespace required before NDATA" ) ; } requireWhitespace ( ) ; String notationName = readNmtoken ( true ) ; if ( ! skippedPE ) { setExternalEntity ( name , ENTITY_NDATA , ids , notationName ) ; handler . unparsedEntityDecl ( name , ids . publicId , ids . systemId , ids . baseUri , notationName ) ; } } else if ( ! skippedPE ) { setExternalEntity ( name , ENTITY_TEXT , ids , null ) ; handler . getDeclHandler ( ) . externalEntityDecl ( name , ids . publicId , handler . resolveURIs ( ) // FIXME: ASSUMES not skipped // "false" forces error on bad URI ? handler . absolutize ( ids . baseUri , ids . systemId , false ) : ids . systemId ) ; } } // Finish the declaration. skipWhitespace ( ) ; require ( ' ' ) ; }
Parse an entity declaration .