public void Expand(Profile.ProfileStructureComponent structure) { if (structure.Differential == null) throw Error.Argument("structure", "structure does not contain a differential specification"); var differential = structure.Differential; var baseStructure = _loader.LocateBaseStructure(structure.TypeElement); if (baseStructure == null) throw Error.InvalidOperation("Could not locate the base profile for type {0}", structure.TypeElement.ToString()); if(baseStructure.Snapshot == null) throw Error.InvalidOperation("Base definition to use for expansion lacks a snapshot representation"); // var baseUri = StructureLoader.BuildBaseStructureUri(structure.TypeElement).ToString(); var snapshot = (Profile.ConstraintComponent)baseStructure.Snapshot.DeepCopy(); //DSTU1 //snapshot.SetStructureForm(StructureForm.Snapshot); //snapshot.SetStructureBaseUri(baseUri.ToString()); //mergeStructure(snapshot, differential); var fullDifferential = new DifferentialTreeConstructor(differential).MakeTree(); var snapNav = new ElementNavigator(snapshot); snapNav.MoveToFirstChild(); var diffNav = new ElementNavigator(fullDifferential); diffNav.MoveToFirstChild(); merge(snapNav, diffNav); //TODO: Merge search params? snapNav.CommitChanges(); structure.Snapshot = snapNav.Elements; }