Beispiel #1
0
        // The prefix to the namespace for the application.

        // Creates an element with the specified localName, in the appropriate namespace for the NOS.
        //
        // If necessary the namespace definition is added to the root element of the doc used to
        // create the element.  The element is not parented but to avoid an error can only be added
        // as a child of another element in the same doc.

        public XElement CreateElement(XDocument doc, string localName, string fullyQualifiedClassName, string singularName, string pluralName)
        {
            XNamespace nsUri = GetUri();

            var element = new XElement(nsUri + localName);

            element.SetAttributeValue(NofMetaModel.Nof + "fqn", fullyQualifiedClassName);
            element.SetAttributeValue(NofMetaModel.Nof + "singular", singularName);
            element.SetAttributeValue(NofMetaModel.Nof + "plural", pluralName);
            NofMetaModel.AddNamespace(element); // good a place as any

            AddNamespace(element, Prefix, GetUri());
            return(element);
        }
Beispiel #2
0
        // Creates an <xs:schema> element for the document
        // to the provided element, attaching to root of supplied Xsd doc.
        //
        // In addition:
        //  - the elementFormDefault is set
        //  - the NOF namespace is set
        //  - the <code>xs:import</code> element referencing the NOF namespace is added  as a child

        public static XElement CreateXsSchemaElement(XDocument xsdDoc)
        {
            if (xsdDoc.Root != null)
            {
                throw new ArgumentException("XSD document already has content");
            }
            XElement xsSchemaElement = CreateXsElement(xsdDoc, "schema");

            xsSchemaElement.SetAttributeValue("elementFormDefault", "qualified");

            NofMetaModel.AddNamespace(xsSchemaElement);

            xsdDoc.Add(xsSchemaElement);
            XElement xsImportElement = CreateXsElement(xsdDoc, "import");

            xsImportElement.SetAttributeValue("namespace", NofMetaModel.Nof.NamespaceName);
            xsImportElement.SetAttributeValue("schemaLocation", NofMetaModel.DefaultNofSchemaLocation);

            xsSchemaElement.Add(xsImportElement);

            return(xsSchemaElement);
        }