Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

How to extend the model via custom additional configurations
xomega
#1 Posted : Wednesday, October 31, 2012 6:55:50 PM(UTC)
xomega



Xomega defines numerous extension points to its business domain and service models, which allow you to provide additional configurations for various model elements that you can leverage either in your customized Xomega generators or any new generators that you may develop.

Generally, you want to define your extensions in a separate XML schema file (XSD) using your own target namespace. This will help you keep your modifications separate from the main Xomega files, which will simplify applying your modifications to a new version of Xomega whenever you upgrade. In fact, this is exactly the same approach that Xomega itself is using to extend the base model with various facets pertaining to different layers or technologies, such as SQL, EDM, WCF, WPF, Web and Xomega Framework. You can view their associated XML schema files to see more examples.

The following steps guide you through the process of extending the model via additional configurations.
  1. Define your own XML schema file with your custom target namespace.
  2. Map an XML prefix to the base Xomega model namespace, e.g. xmlns:o="http://www.xomega.net/omodel".
  3. Import the schema of the base Xomega model as follows.
    Code:
    <xs:import namespace="http://www.xomega.net/omodel" schemaLocation="Xomega.xsd"/>

  4. Decide which element in the base Xomega model you want to define additional configuration for. Typically, any additional configuration goes inside the config element of the associated model element except for the documentation node, where it goes directly inside the doc element. This is your extension point.
  5. Find an abstract element in the base Xomega model schema that is defined inside your extension point (e.g. the config element). To do that, you can put the cursor on any of the corresponding elements in the model and select Go To Definition or press F12. This will take you to the underlying schema file, where you need to find the corresponding complex type definition and the abstract element that it contains.
  6. Define a new element in your custom schema file, e.g. myelement. Set the substitutionGroup attribute to the name of the abstract element that you found in the previous step. Also, make the complex type for your element extend the type that is used by that abstract element.
  7. Ensure that your schema file is included in the Visual Studio XML schema set from the XML > Schemas menu option.
  8. Add your custom namespace to your model file under a certain prefix, e.g. xmlns:mycfg="http://www.myorg.com/xomega/mycfg".
  9. Try adding an element inside your extension point. The Visual Studio Intellisense should display your prefix and your element name as follows.
    Code:
    <config>
      <mycfg:myelement myattr="myvalue"/>
    </config>

The following example shows how a schema file for the "http://www.xomega.net/framework" namespace defines a new extension element enumerations for the global model configuration, which allows specifying the namespace for the generated enumerations classes. It uses the abstract element o:model-extension from the base model and extends its base type o:modelConfigurationExtension.
Code:
<xs:schema xmlns="http://www.xomega.net/framework" xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:o="http://www.xomega.net/omodel" xmlns:xom="urn:xomega-net:language"
           targetNamespace="http://www.xomega.net/framework"
           elementFormDefault="qualified" attributeFormDefault="unqualified" version="1.0">
  <xs:import namespace="http://www.xomega.net/omodel" schemaLocation="Xomega.xsd"/>
  <xs:element name="enumerations" substitutionGroup="o:model-extension">
    <xs:annotation>
      <xs:documentation>Global enumerations configuration.</xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:complexContent>
        <xs:extension base="o:modelConfigurationExtension">
          <xs:attribute name="namespace" type="o:fullClassName">
            <xs:annotation>
              <xs:documentation>The namespace for the generated enumeration classes.</xs:documentation>
            </xs:annotation>
          </xs:attribute>
        </xs:extension>
      </xs:complexContent>
    </xs:complexType>
  </xs:element>
</xs:schema>


The following list details various abstract extension point elements defined in the Xomega model along with their base types.
  1. doc-extension abstract element is used to extend any documentation nodes for various model elements with custom tags. It is defined inside the doc elements and uses a complex type that extends from docExtension.
  2. model-extension abstract element is used to extend the global model configuration with any custom information. It is defined inside the config element of the module elements and uses a complex type that extends from modelConfigurationExtension.
  3. type-extension abstract element is used to extend a logical type configuration with any custom information. It is defined inside the config element of the type elements and uses a complex type that extends from typeConfigurationExtension.
  4. object-extension abstract element is used to extend an object configuration with any custom information. It is defined inside the config element of the object elements and uses a complex type that extends from objectConfigurationExtension.
  5. field-extension abstract element is used to extend a field configuration with any custom information. It is defined inside the config element of the field elements and uses a complex type that extends from fieldConfigurationExtension.
  6. fieldset-extension abstract element is used to extend a field set configuration with any custom information. It is defined inside the config element of the fieldset elements and uses a complex type that extends from fieldsetConfigurationExtension.
  7. operation-extension abstract element is used to extend an operation configuration with any custom information. It is defined inside the config element of the operation elements and uses a complex type that extends from operationConfigurationExtension.
  8. parameters-extension abstract element is used to extend any parameter configuration with any custom information. It is defined inside the config element of the parameter elements and uses a complex type that extends from parametersConfigurationExtension.
  9. enum-extension abstract element is used to extend an enumeration configuration with any custom information. It is defined inside the config element of the enumeration elements and uses a complex type that extends from enumConfigurationExtension.
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.