TOP

Library net/mdatools/modelant/uml13/reverse/antlib.xml

Tasks, types and macros of ModelAnt UML 1.3 Reverse Engineering
Usage:

<typedef resource="net/mdatools/modelant/uml13/reverse/antlib.xml"/>

Imports:

<typedef resource="net/mdatools/modelant/uml13/wrap/antlib.xml"/>
<typedef resource="net/mdatools/modelant/template/antlib.xml"/>
Tasks and Macros Description
ant.doc Generate documentation of all tasks/types/macros in modelant, integrated with its javadoc documentation.
     Usage:
     <ant.doc output.dir="${root.doc}/antlibdoc" javadoc.dir="../api" java.model="${out}/reverse.java.xmi" work.dir="${work}">
       <fileset dir="util/src/xml">
         <include name="**/antlib.xml" />
       </fileset>

       <fileset dir="mdr/src/xml">
         <include name="**/antlib.xml" />
       </fileset>
     </ant.doc>
     
See reverse.ant
convert.dtd2xsd Convert a DTD into XSD
Based on Trang Manual

Based on Version 20081028

DTD input module

This input module accepts DTDs as defined by the XML 1.0 Recommendation.

It accepts the following INPUT parameters:

xmlns=uri Specifies the default namespace, that is the namespace used for unqualified element names.
xmlns:prefix=uri Specifies the namespace for the element and attribute names using prefix.
colon-replacement=chars Replaces colons in element names by chars when constructing the names of definitions used to represent the element declarations and attribute list declarations in the DTD. Trang generates a definition for each element declaration and attlist declaration in the DTD. The name of the definition is based on the name of the element. In RELAX NG, the names of definitions cannot contain colons. However, in the DTD, the element name may contain a colon. By default, Trang will first try to use the element names without prefixes. If this causes a conflict, it will instead replace the colon by a legal name character (it try first to use a period).
element-define=name-pattern Specifies how to construct the name of the definition representing an element declaration from the name of the element. The name-pattern must contain exactly one percent character. This percent character is replaced by the name of element (after colon replacement) and the result is used as the name of the definition.
inline-attlist Specifies not to generate definitions for attribute list declarations and instead move attributes declared in attribute list declarations into the definitions generated for element declarations. This is the default behavior when the output module is xsd. Otherwise, the default behaviour is as described in the nonline-attlist parameter.
nonline-attlist Generates a distinct definition (with combine="interleave") for each attribute list declaration in the DTD; the definition for each element declaration references the definition for the corresponding attribute list declaration. This is the default behavior, except when the output module is xsd, for which the default behavior is as described in the inline-attlist parameter.
attlist-define=name-pattern This specifies how to construct the name of the definition representing an attribute list declaration from the name of the element. The name-pattern must contain exactly one percent character. This percent character is replaced by the name of element (after colon replacement) and the result is used as the name of the definition.
any-name=name Specifies the name of the definition generated for the content of elements declared in the DTD as having a content model of ANY.
strict-any Preserves the exact semantics of ANY content models by using an explicit choice of references to all declared elements. By default, Trang uses a wildcard that allows any element.
annotation-prefix=prefix Default values are represented using an annotation attribute prefix:defaultValue where prefix is bound to http://relaxng.org/ns/compatibility/annotations/1.0 as defined by the RELAX NG DTD Compatibility Committee Specification. By default, Trang will use a for prefix unless that conflicts with a prefix used in the DTD.
generate-start
no-generate-start Specifies whether Trang should generate a start element. DTDs do not indicate what elements are allowed as document elements. Trang assumes that all elements that are defined but never referenced are allowed as document elements.

W3C XML Schema output module

This output module outputs an W3C XML Schema as defined by the XML Schema Recommendation.

It supports the following OUTPUT parameters:

encoding=name Use an encoding of name for the output files.
indent=n Indent by n spaces for each indentation level.
disable-abstract-elements Disables the use of abstract elements and subsitution groups in the generated XML Schema. This can also be controlled using an annotation attribute.
any-process-contents=strict|lax|skip Specifies the value for the processContents attribute of any elements. The default is skip (corresponding to RELAX NG semantics) unless the input format is dtd, in which case the default is strict (corresponding to DTD semantics).
any-attribute-process-contents=strict|lax|skip Specifies the value for the processContents attribute of anyAttribute elements. The default is skip (corresponding to RELAX NG semantics).

It has the following limitations:

  • it may generate schemas that violate W3C XML Schema's restrictions on ambiguous content models;
  • it may generate schemas that violate W3C XML Schema's restrictions on consistent element types;
  • when the RELAX NG schema cannot be represented by W3C XML Schema, a generalization is generated; it should give a warning in this case, but does not always do so.

Annotations can be added to the RELAX NG schema to guide the translation. These annotations have the namespace URI http://www.thaiopensource.com/ns/relaxng/xsd. This document will use the convention that the prefix tx refers to this namespace URI; in other words, it will assume a namespace declaration of

xmlns:tx="http://www.thaiopensource.com/ns/relaxng/xsd"

Currently, only one annotation is supported, an attribute tx:enableAbstractElements. The value of this must be true or false. It applies to RELAX NG define elements. Trang has the ability to translate a define that contains a choice of element patterns into an abstract element declaration, which will be used as the head of a substitution group whose members are the elements in the choice. Whether it does this is determined by the value of the tx:enableAbstractElements annotation attribute. If the value is true, it will attempt to use an abstract element element. If the value is false, it will not, which means the define will typically be translated into a group definition.

The tx:enableAbstractElements attribute is inherited in a similar way to the ns attribute: it can be specified on a grammar, div or include element to enable or disable the use of abstract elements for all descendant define elements. In the absence of any inherited tx:enableAbstractElements attribute, the use of abstract elements is enabled unless the disable-abstract-elements option was specified.

It can happen that the same element name occurs in a choice in more than one define element; at most one of these define elements can be translated to an abstract element. In this case, Trang will not translate any of them to an abstract element, unless the use of abstract elements has been disabled by tx:enableAbstractElements for all except one of the define elements.

In fact, the use of abstract elements is not restricted to the case where the define consists of a choice that contains only element patterns; the choice may also contain ref patterns referring to definitions that are to be translated into element declarations, whether abstract or not. The tx:enableAbstractElements attribute applies equally to these definitions.

Convert a DTD into an XSD
diff.db Compare two models and prints the differences. Both models are treated as reverse engineered structures of different versions of the same database. They could have been built by using the <reverse.db> macro. The model comparison is done using the <uml13.compare.models>. The assumption that the models are of database schema is reflected only in the simplification of the output of classes, attributes and associations.
reverse.ant Reverse engineer Ant script and library files, in terms of defined tasks, macros, types and targets. Represent them as classes, attributes and generaliizations in a UML 1.3 model. This class implements reverse engineering logic for Ant Antlib definitions of types, tasks and macros with the goal to register and document them together with any comments bound to them
 Usage:
   <reverse.ant
     output="..."/>
 
Conventions for the model produced:
  1. The comments before the type/task/macro def statement are adopted as comments of the defined object
  2. The comments before the attribute/element definition are adopted as documentation of the
  3. Any explicit descriptions are added after any explicit comments
  4. The typdef/taskdef/macrodef way of defining the result class are set as its stereotype
  5. The implementation class of typdef/taskdef is represented as a superclass of the defined model element
  6. Any default values are set as default attribute values
  7. Each script reverse engineered is represented as a package, following the file path to it, whereas the file name, without the extension, is stored as package name
  8. For each script reverse engineered, the corresponding package contains its name assigned as a tagged value with tag = 'file.name'
This task requires the UML 1.3 Core wrappers are in classpath and the corresponding UML 1.3 factory is registered
The class is not thread safe
reverse.db Reverse engineer a database schema and represents its tables, fields, relationships as classes, attributes, associations in a UML 1.3 model. This task implements reverse engineering logic for database schemas and storing the results as UML 1.3 objects. The model produced is in fact a Platform Specific Model, which might need additional processing and tuning.

Usage:

   <reverse.db
     url="jdbc:oracle:thin:&atlocalhost:1521:vegas"
     user="..."
     password="..."
     driver="oracle.jdbc.driver.OracleDriver"
     schema="..."
     output="..."/>
 
The class is not thread safe

Conventions for the model produced:

  1. The database column types are converted to DataType instances named: <type name>[_<column size>[_<column precision>]]. Additionally as tagged values named TAG_VALUE_DATA_TYPE_SIZE and TAG_VALUE_DATA_TYPE_PRECISION these values are bound to the concrete data type.
  2. The TAG_VALUE_DATA_TYPE_PRECISION tagged value is optional. When not provided, the precision should be treated as 0
  3. The TAG_VALUE_DATA_TYPE_SIZE tagged value is mandatory.
  4. Any comments found while reverse engineering the database are bound as 'documentaion' tagged values. These tagged values are compatible with the Rose's approach to documentation. They are optional.
  5. Each attribute created might have TAG_VALUE_NULLABLE tagged value assigned. When provided it contains 'false' to indicate attributes that cannot be null. True values are not provided.
  6. Each attribute pertaining to the table's primary key is bound a 'primary_key' tagged value Its value is the sequence order of the column in the tible's primary key.
This task shuts down the models repository, so any further processing of models in the same JVM process becomes impossible. If one would be needed, do it in a separate run.
reverse.dtd Reverse engineer a DTD as an UML 1.3 model following the conventions for XSD, applying an interim transformation DTD-toXSD. See the convert.dtd2xsd task for the nested elements of this macro.
reverse.java Reverse engineer a set of java files by representing in the result UML 1.3 model the classes, attributes and methods in the java classes in-scope. The model represents the structure of the code and does NOT represent its behavior.
      Usage:

      <reverse.java output.file="${out}/reverse.java.xmi" target.classpathref="classpath">
        <packageset dir="util/src/java" defaultexcludes="yes">
          <include name="**" />
        </packageset>

        <packageset dir="mdr/src/java" defaultexcludes="yes">
          <include name="**" />
        </packageset>

      </reverse.java>
      
reverse.xsd Reverse engineer XML schema(s) and represents the elements, nesting as classes, attributes, compositions in a UML 1.3 model. This class implements reverse engineering logic for XML schemas and storing the results as UML 1.3 objects. The model produced is in fact a Platform Specific Model, which might need additional processing and tuning.

Usage:

   <reverse.xsd output="...">
     <fileset .... />
   </reverse.xsd>  
 
Conventions for the model produced:
  • The model elements (classes, association names) that represent elements in the output XML are marked with <<element>> stereotype
  • For representation purposes local types (UML classes) could be introduced for XSD groups, unions, local / inlined types. All of them are marked with <<local type>> stereotype
  • The column types are converted to DataType instances named: <type name>[_<column size>[_<column precision>]]. Additionally as tagged values named TAG_VALUE_DATA_TYPE_SIZE and TAG_VALUE_DATA_TYPE_PRECISION these values are bound to the concrete data type.
  • The TAG_VALUE_DATA_TYPE_PRECISION tagged value is optional. When not provided, the precision should be treated as 0
  • Any comments found while reverse engineering the XSD are bound as 'documentation' tagged values. These tagged values are compatible with the Rose's approach to documentation. They are optional.

Documentation generated by ant.doc Ant macro from ModelAnt by MDA Tools