+ // Determine if the requested QName can be satisfied from the prototype: for that to happen it has to match
+ // our transformation implied by targetModule.
+ final var requestedNamespace = qname.getModule();
+ final QName templateQName;
+ if (targetModule != null) {
+ if (!targetModule.equals(requestedNamespace)) {
+ return null;
+ }
+ templateQName = qname.bindTo(StmtContextUtils.getRootModuleQName(prototype));
+ } else {
+ if (!StmtContextUtils.getRootModuleQName(prototype).equals(requestedNamespace)) {
+ return null;
+ }
+ templateQName = qname;
+ }
+