private void recoverReference(Document doc, XMLDoc xdoc) { string p = System.IO.Path.GetDirectoryName(doc.FullDocumentName); foreach (DocumentDescriptor d in doc.ReferencedDocumentDescriptors) { string fdn = d.FullDocumentName; XElement el = xdoc.find("old", fdn); if (el == null) { el = xdoc.find("old", System.IO.Path.Combine(p, System.IO.Path.GetFileName(fdn))); } if (d.FullDocumentName.EndsWith("iam")) { Document rd = d.ReferencedDocument as Document; if (rd == null && el != null) { string n = System.IO.Path.Combine(p, System.IO.Path.GetFileName(el.Attribute("new").Value)); if (System.IO.File.Exists(n)) { rd = I.open(n); } } if (rd != null) { recoverReference(rd, xdoc); } } if (d.ReferenceMissing) { if (el != null && System.IO.File.Exists(el.Attribute("new").Value)) { d.ReferencedFileDescriptor.ReplaceReference(el.Attribute("new").Value); } } } }