322 revertToStochastic = []
326 nsid = doc.getNamespaceId()
327 dependencies = doc.getNamespaceDependencies()
328 for d
in dependencies:
329 if d != nsid
and d != 0:
331 nsUri = doc.getReferencedNamespaceUri(d)
332 logger.info(
"Need a namespace referenced as " +
str(d) +
". Which hopefully is " + nsUri)
337 if tgt.getReferencedNamespaceUri(1) == nsUri:
340 if not targetDoc ==
None:
342 doc.reassignReferencedNamespaceId(d, targetDoc.getNamespaceId())
345 revertToStochastic.append((doc, d))
346 logger.warn(
"Failed to reliably identify which XML/Model " + os.path.basename(doc.originXML) +
" calls ns=" +
str(d))
348 for (doc, d)
in revertToStochastic:
349 logger.warn(
"Attempting to find stochastic match for target namespace ns=" +
str(d) +
" of " + os.path.basename(doc.originXML))
353 for ref
in doc.referencedNodes:
357 tDocId = tDoc.getNamespaceId()
366 matches.append((c, tDoc))
373 logger.warn(
"Best match (" +
str(best[1]*100) +
"%) for what " + os.path.basename(doc.originXML) +
" refers to as ns="+
str(d)+
" was " + os.path.basename(best[1].originXML))
374 doc.reassignReferencedNamespaceId(d, best[1].getNamespaceId())
376 logger.error(
"Failed to find a match for what " + os.path.basename(doc.originXML) +
" refers to as ns=" +
str(d))