BZ-1051469 - NPE when building project with kbase or ksession that are not in xsd:ID format

(cherry picked from commit 2f2cc6cdb1c17a494786c8746f549812e6b67c98)
(cherry picked from commit ed4616e192147203eb5a6c9bb5056066e2344550)