#544 QName(uri, lex) with invalid prefix

v8.7.3
closed
Michael Kay
5
2012-10-08
2006-06-18
Michael Kay
No

When the function fn:QName() is called and the second
argument is a name containing a ":", but whose prefix
is not a valid NCName, Saxon fails to detect the error.

Source fix: At line 38 of QNameFn.java (immediately
before the "return" statement), add

        // The QNameValue constructor does not

check the prefix
if (!checker.isValidNCName(parts[0])) {
DynamicError err = new
DynamicError("Malformed prefix in QName: '" + parts[0]
+ '\'');
err.setErrorCode("FORG0001");
throw err;
}

Test case: K-ExpandedQNameConstructFunc-5 in XQTS

Discussion

  • Michael Kay
    Michael Kay
    2006-06-18

    Logged In: YES
    user_id=251681

    The same code needs to be added at the equivalent place in
    the evaluateItem() method of the same module, to catch the
    case where the arguments are evaluated at run-time rather
    than at compile-time.

     
  • Michael Kay
    Michael Kay
    2006-06-19

    Logged In: YES
    user_id=251681

    The patch is incorrect, because it rejects an empty prefix
    as well as an invalid prefix. In both locations, the correct
    code to insert is:

    if (!parts[0].equals("") && !checker.isValidNCName(parts[0])) {
    DynamicError err = new
    DynamicError("Malformed prefix in QName: '" + parts[0] + '\'');
    err.setErrorCode("FORG0001");
    throw err;
    }

     
  • Michael Kay
    Michael Kay
    2006-06-19

    Logged In: YES
    user_id=251681

    The patch is incorrect, because it rejects an empty prefix
    as well as an invalid prefix. In both locations, the correct
    code to insert is:

    if (!parts[0].equals("") && !checker.isValidNCName(parts[0])) {
    DynamicError err = new
    DynamicError("Malformed prefix in QName: '" + parts[0] + '\'');
    err.setErrorCode("FORG0001");
    throw err;
    }