Create a heirarchical document (Model -> Package(s) -> Classes)

I have looked in the VP documents and searched on-line, but cannot find an easy answer to what I am trying to do.

I have a project that I want to document. From the trunk I have a series of models. Some of these models have sub-models. The models also have packages, some of which also contain packages. Finally, we get down to the classes within the packages. As an aside, I currently have some classes under models, not under packages - but I can clean those up if required.

I woudl like to create a document that lists/explains all the classes in the project. This, by itself, is relatively easy through . But I would like to structure this document through the Models and Packages. For example:

1 Model X
1.1 Sub-Models

  • Model 1
  • Model 2

1.2 Package List

  • Package 1
  • Package 2

1.3 - 1.n [Package Details] Package:
1.3.1 Sub-Package list

  • Sub-package 1
  • Sub-package 2

1.3.2 Classes

  • Class 1
  • Class 2

While a sub-model would be listed as belonging to a particular model, the sub-model would get its own Level-1 heading when exposing the details (i.e. the document is not intended to be infinitely recursive). Similarly for packages under a model.

The key thing for me is that the classes are described under the relevant packages, and not just listed without context. Particularly because a couple of the packages have similar class names within.

What I have tried is to call a document template XML snippet recursively, but did not get any results from that. Any guidance would be greatly appreciated.

Sorry for late reply.

About how to generate the Model / Package / Classes, the following sample may help you:

What I have tried is to call a document template XML snippet recursively, but did not get any results from that.

I think there may be something wrong in your template, would you mind post your template here, let me try to find out the problem?

I can’t believe I did not find the linked How-To article in all my searching! I would like to post my snippet, but in my various attempts I think I totally destroyed my logic. Looking back over my two main attempts:

  • one specific example I created a copy and called the original snippet instead of the new one (i.e. ‘Report2’ called ‘Report’, not ‘Report2’
  • the other example I did have the correct ‘Reference’ call, but something may have been not happening, because I commented it out. I include this snippet below:
    < ?xml version="1.0" encoding="UTF-8"?>
        < LoopTemplate>
	< IterationBlock>
		< ValueChecker property="modelType" operator="equals" value="Package" >
			< Reference template="Details" />
			< IterationBlock>
				< ValueChecker property="modelType" operator="equals" value="Package" >
					< Reference template="Details" />
				< /ValueChecker>

			< /IterationBlock>

			< !-- <Reference template="DNCustomLoop" />		-->	
		< /ValueChecker>
		< ValueChecker property="modelType" operator="not equals" value="Package" >
			< Reference template="@default" />
		< /ValueChecker>
	< /IterationBlock>
< /LoopTemplate>

types ``` on top and bottom of your code
e.g.

   AAA
BBB
   CCC
DDD

Sorry, seems your logic are destroyed, let me try to prepare a sample for you.

  1. Defines the template XML for Model & Package
<?xml version="1.0" encoding="UTF-8"?>
<ElementBaseInitiationBlock>
	<Inline template="Basic"/>

	<IterationBlock>
		<Conditions>
			<ValueChecker property="modelType" operator="equals" value="Model"/>
		</Conditions>
		
		<Reference template="Hierarchy"/>
	</IterationBlock>
	
	<IterationBlock>
		<Conditions>
			<ValueChecker property="modelType" operator="equals" value="Package"/>
		</Conditions>
		
		<Reference template="Hierarchy"/>
	</IterationBlock>
	
	<IterationBlock>
		<Conditions>
			<ValueChecker property="modelType" operator="not equals" value="Model"/>
			<ValueChecker property="modelType" operator="not equals" value="Package"/>
		</Conditions>
		
		<Reference template="@default"/>
	</IterationBlock>
</ElementBaseInitiationBlock>
  1. Result

PS:
on my above sample, I doesn’t use <LoopTemplate>, it is because there is a limitation when using it recursively.

Thanks for that help. This is the current draft of code which gives me the result I desire - I am posting here for future reference as it may help someone else. I currently (as you noted in your answer above) have this duplicated in both the Model and Package sections. As such, I have given it a slightly different name for each section - a descriptive name, so ‘ModelDetails’ doesn’t make as much sense under Package.

Would I be better coding this as a General snippet, and then Reference it from the Model and Package elements in a single line SML snippet?

<?xml version="1.0" encoding="UTF-8"?>
<ElementBaseInitiationBlock>
	<Text style="Heading 2">Package: </Text>
	<Property property="name"/>
	<ParagraphBreak/>
	<HasChildElementChecker modelType="Model,Package,Class">
		<Text style="@heading+">Child models and packages</Text>
		<ParagraphBreak/>
		<TableBlock tableWidth="100%" colWidths="1,2,4" tableStyle="TableGrid">
			<TableRow>
				<TableCell><Text>Element type</Text></TableCell>
				<TableCell><Text>Name</Text></TableCell>
				<TableCell><Text>Description</Text></TableCell>
			</TableRow>
			<IterationBlock>
				<Conditions>
					<ValueChecker property="modelType" operator="equals" value="Model"/>
				</Conditions>
				<TableRow>
					<TableCell><Text>Model</Text></TableCell>
					<TableCell><Property property="name"/></TableCell>
					<TableCell><Property property="description"/></TableCell>
				</TableRow>
			</IterationBlock>
			<IterationBlock>
				<Conditions>
					<ValueChecker property="modelType" operator="equals" value="Package"/>
				</Conditions>
				<TableRow>
					<TableCell><Text>Package</Text></TableCell>
					<TableCell><Property property="name"/></TableCell>
					<TableCell><Property property="description"/></TableCell>
				</TableRow>
			</IterationBlock>
			<IterationBlock>
				<Conditions>
					<ValueChecker property="modelType" operator="equals" value="Class"/>
				</Conditions>
				<TableRow>
					<TableCell><Text>Class</Text></TableCell>
					<TableCell><Property property="name"/></TableCell>
					<TableCell><Text>See separate explanation below</Text></TableCell>
				</TableRow>
			</IterationBlock>
		</TableBlock>
	</HasChildElementChecker>
	
	<Reference template="General/DN_SubDiagrams"/>

	<HasChildElementChecker modelType="Class">
		<IterationBlock>
			<Conditions>
				<ValueChecker property="modelType" operator="equals" value="Class"/>
			</Conditions>
			<Reference template="General/DN_ClassDetails"/>
		</IterationBlock>
	</HasChildElementChecker>
	
		
	<IterationBlock>
		<Conditions>
			<ValueChecker property="modelType" operator="equals" value="Model"/>
		</Conditions>
		
		<Reference template="DN_ModelDetails"/>
	</IterationBlock>
	
	<IterationBlock>
		<Conditions>
			<ValueChecker property="modelType" operator="equals" value="Package"/>
		</Conditions>
		
		<Reference template="DN_PackageDetails"/>
	</IterationBlock>
	
</ElementBaseInitiationBlock>

DN_ClassDetails’ is currently a copy of the default Class Details snippet, which I will tailor to meet my needs at some stage.