public static Map < String , Vocab > parsePrefixDeclaration ( String value , Map < String , ? extends Vocab > predefined , Map < String , ? extends Vocab > known , Set < String > forbidden , Report report , EPUBLocation location ) { Map < String , Vocab > vocabs = Maps . newHashMap ( predefined ) ; Map < String , String > mappings = PrefixDeclarationParser . parsePrefixMappings ( value , report , location ) ; for ( Entry < String , String > mapping : mappings . entrySet ( ) ) { String prefix = mapping . getKey ( ) ; String uri = mapping . getValue ( ) ; if ( "_" . equals ( prefix ) ) { // must not define the '_' prefix report . message ( MessageId . OPF_007a , location ) ; } else if ( forbidden . contains ( uri ) ) { // must not declare a default vocab report . message ( MessageId . OPF_007b , location , prefix ) ; } else { if ( predefined . containsKey ( prefix ) && ! Strings . nullToEmpty ( predefined . get ( prefix ) . getURI ( ) ) . equals ( uri ) ) { // re-declaration of reserved prefix report . message ( MessageId . OPF_007 , location , prefix ) ; } Vocab vocab = known . get ( uri ) ; vocabs . put ( mapping . getKey ( ) , ( vocab == null ) ? new UncheckedVocab ( uri , prefix ) : vocab ) ; } } return ImmutableMap . copyOf ( vocabs ) ; }
Parses a prefix attribute value and returns a map of prefixes to vocabularies given a pre - existing set of reserved prefixes known vocabularies and default vocabularies that cannot be re - declared .