// Start a snapshot at the root object, using own namespace manager. // Creates an XElement representing this object, and appends it as the root // element of the Document. // // The Document must not yet have a root element Additionally, the supplied // schemaManager must be populated with any application-level namespaces // referenced in the document that the parentElement resides within. // (Normally this is achieved simply by using AppendXml passing in a new // schemaManager - see ToXml() or XmlSnapshot). private Place AppendXml(INakedObjectAdapter nakedObjectAdapter) { var fullyQualifiedClassName = nakedObjectAdapter.Spec.FullName; Schema.SetUri(fullyQualifiedClassName); // derive URI from fully qualified name var place = ObjectToElement(nakedObjectAdapter); var element = place.XmlElement; var xsElementElement = element.Annotation <XElement>(); XmlDocument.Add(element); XsdElement.Add(xsElementElement); Schema.SetTargetNamespace(XsdDocument, fullyQualifiedClassName); var schemaLocationFileName = fullyQualifiedClassName + ".xsd"; Schema.AssignSchema(XmlDocument, fullyQualifiedClassName, schemaLocationFileName); XmlElement = element; SchemaLocationFileName = schemaLocationFileName; return(place); }
// Creates an XElement representing this object, and appends it as the root // element of the Document. // // The Document must not yet have a root element Additionally, the supplied // schemaManager must be populated with any application-level namespaces // referenced in the document that the parentElement resides within. // (Normally this is achieved simply by using AppendXml passing in a new // schemaManager - see ToXml() or XmlSnapshot). private Place AppendXml(INakedObject nakedObject) { Log.Debug("appendXml(" + DoLog("obj", nakedObject) + "')"); string fullyQualifiedClassName = nakedObject.Spec.FullName; Schema.SetUri(fullyQualifiedClassName); // derive URI from fully qualified name Place place = ObjectToElement(nakedObject); XElement element = place.XmlElement; var xsElementElement = element.Annotation <XElement>(); Log.Debug("appendXml(NO): add as element to XML doc"); XmlDocument.Add(element); Log.Debug("appendXml(NO): add as xs:element to xs:schema of the XSD document"); XsdElement.Add(xsElementElement); Log.Debug("appendXml(NO): set target name in XSD, derived from FQCN of obj"); Schema.SetTargetNamespace(XsdDocument, fullyQualifiedClassName); Log.Debug("appendXml(NO): set schema location file name to XSD, derived from FQCN of obj"); string schemaLocationFileName = fullyQualifiedClassName + ".xsd"; Schema.AssignSchema(XmlDocument, fullyQualifiedClassName, schemaLocationFileName); Log.Debug("appendXml(NO): copy into snapshot obj"); XmlElement = element; SchemaLocationFileName = schemaLocationFileName; return(place); }