#524 NPE with invalid key() name

v8.7.1
closed
Michael Kay
5
2012-10-08
2006-05-19
Michael Kay
No

If the first argument of the key() function is computed
dynamically rather than being supplied as a string
literal, and if the value supplied is not the name of
any key definition in the stylesheet, a
NullPointerException may occur.

Source fix:

in KeyManager.java line 429, change

  KeyDefinition definition =

(KeyDefinition)getKeyDefinitions(fingerprint).get(0);

to:

    List definitions = getKeyDefinitions(fingerprint);
    if (definitions == null) {
        DynamicError de = new DynamicError("Key " +

context.getNamePool().getDisplayName(fingerprint) +
" has not
been defined");
de.setXPathContext(context);
de.setErrorCode("XTDE1260");
throw de;
}
KeyDefinition definition =
(KeyDefinition)definitions.get(0);

Discussion