.// Copyright (c) 2007-2010 by Kavanagh Consultancy Limited. All rights reserved.
.//
.Assign tab = "  "
.//
.Function objectDescription
.Param inst_ref object
.Param string indent
    .// Heading
${indent}<h3>\
    .If (object.Number > 0)
${object.Number}. \
    .End if
$u{object.Name}\
    .If (object.KeyLetters != "")
 (${object.KeyLetters})\
    .End if
</h3>
    .//
${indent}<table border="0">
${indent}${tab}<tr>
${indent}${tab}${tab}<td width="40"></td>
${indent}${tab}${tab}<td>
    .//
    .// Object Summary
${indent}${tab}${tab}${tab}<table border="0">
${indent}${tab}${tab}${tab}${tab}<tr>
${indent}${tab}${tab}${tab}${tab}${tab}<td width="40"></td>
${indent}${tab}${tab}${tab}${tab}${tab}<td valign="top"><nobr>${object.Name} (</nobr></td>
    .Select many attributes related by object->Attribute[R106]
    .For each attribute in attributes
        .If (first attributes)
${indent}${tab}${tab}${tab}${tab}${tab}<td><nobr>\
        .Else
, <wbr>\
        .End if
        .Select one preferredIdentifier related by attribute->IdentifyingAttribute[R111]->Identifier[R111] where (selected.Preferred == true)
        .If (not_empty preferredIdentifier)
<u>${attribute.Name}</u>\
        .Else
${attribute.Name}\
        .End if
        .If (last attributes)
 )</nobr></td>
        .End if
    .End for
${indent}${tab}${tab}${tab}${tab}</tr>
${indent}${tab}${tab}${tab}</table>
    .//
    .// Identifiers
    .Select many identifiers related by object->Identifier[R110]
    .For each identifier in identifiers
        .If (first identifiers)
${indent}${tab}${tab}${tab}<p><i>Identifiers:</i>
${indent}${tab}${tab}${tab}${tab}<table border="0">
        .End if
${indent}${tab}${tab}${tab}${tab}${tab}<tr>
${indent}${tab}${tab}${tab}${tab}${tab}${tab}<td width="40"></td>
        .Select many identifyingAttributes related by identifier->IdentifyingAttribute[R111]
        .For each identifyingAttribute in identifyingAttributes
            .If (first identifyingAttributes)
${indent}${tab}${tab}${tab}${tab}${tab}${tab}<td><nobr>\
            .Else
 <wbr>+ \
            .End if
${identifyingAttribute->Attribute[R111].Name}\
            .If (last identifyingAttributes)
</nobr></td>
            .End if
        .End for
${indent}${tab}${tab}${tab}${tab}${tab}</tr>
        .If (last identifiers)
${indent}${tab}${tab}${tab}${tab}</table>
${indent}${tab}${tab}${tab}</p>
        .End if
    .End for
    .//
    .If (object.Description != "")
${indent}${tab}${tab}${tab}<p>${object.Description}</p>
    .End if
    .//
    .Select many attributes related by object->Attribute[R106]
    .For each attribute in attributes
        .Invoke attributeDescription (attribute, "${indent}${tab}${tab}${tab}")
    .End for
${indent}${tab}${tab}</td>
${indent}${tab}</tr>
${indent}</table>
.End function
.//
.Function attributeDescription
.Param inst_ref attribute
.Param string indent
    .// Heading
    .Select one object related by attribute->Object[R106]
    .Assign attributeNumber = (attribute.Order + 1)
${indent}<h4>\
    .If (object.Number > 0)
${object.Number}.${attributeNumber}. \
    .End if
${object.Name}.${attribute.Name}</h4>
    .//
    .If (attribute.Description != "")
${indent}${tab}${tab}${tab}<p>${attribute.Description}</p>
    .End if
.End function
.//
.Select many informationModels from instances of InformationModel
.For each informationModel in informationModels
    .Select many subsystems related by informationModel->Subsystem[R136]
    .If ((cardinality subsystems) == 0)
<html>
${tab}<head>
${tab}${tab}<title>Information Model Report for ${informationModel.Name}</title>
${tab}${tab}<meta name="generator" content="OOA Tool">
.//${tab}${tab}<meta name="keywords" content="">
${tab}</head>
${tab}<body>
${tab}${tab}<h1 align="center">${informationModel.Name}</h1>
${tab}${tab}<h2 align="center">Part II: Objects and Attributes</h2>
        .Select many objects related by informationModel->Object[R105]
        .For each object in objects
            .Invoke objectDescription (object, "${tab}${tab}${tab}")
        .End for
${tab}${tab}<h2 align="center">Part III: Relationships</h2>
${tab}</body>
</html>
        .Emit to file "$r{informationModel.Name}.html"
    .Else
        .For each subsystem in subsystems
<html>
${tab}<head>
${tab}${tab}<title>Information Model Report for ${subsystem.Name}</title>
${tab}${tab}<meta name="generator" content="OOA Tool">
.//${tab}${tab}<meta name="keywords" content="">
${tab}</head>
${tab}<body>
${tab}${tab}<h1 align="center">${subsystem.Name}</h1>
${tab}${tab}<h2 align="center">Part II: Objects and Attributes</h2>
        .Select many objects related by subsystem->Object[R137]
        .For each object in objects
            .Invoke objectDescription (object, "${tab}${tab}${tab}")
        .End for
${tab}${tab}<h2 align="center">Part III: Relationships</h2>
${tab}</body>
</html>
            .Emit to file "$r{subsystem.Name}.html"
        .End for
    .End if
.End for