Report composer, problem iterating thru attributes on a class diagram


#1

I am trying to create a report where I display the classes on a class diagram and the attributes associated to the class.
I am able to loop thru the classes but I can’t figure out how to loop thru the attributes of a class.
Any help would be appreciated.
Here’s the template I am using:


<?xml version="1.0" encoding="UTF-8"?>
<Template>
	<TemplateInformationHeader default="false"
		description="/" id="ClassWithAttributes" name="ClassWithAttributes"
		type="table" />
	<DiagramBaseInitiationBlock>
		<StaticText content="Children" style="Heading 2 (VP)" />
		<ParagraphBreak />
		<HasChildElementChecker flag="true">
			<TableBlock alignment="right" colWidths="5000,5000"
				tableWidth="14500">
				<TableRow>
					<TableCell color="230, 230, 230" leftBorderEnable="false"
						rightBorderEnable="false">
						<StaticText content="Name" style="Column header 1" />
					</TableCell>
					<TableCell color="230, 230, 230" leftBorderEnable="false"
						rightBorderEnable="false">
						<StaticText content="Type" style="Column header 1" />
					</TableCell>
				</TableRow>
				<IterationBlock modelType="Class">
					<TableRow>
						<TableCell leftBorderEnable="false" rightBorderEnable="false">
							<StringPropertyText propertyText="name"
								style="Table Contents" />
						</TableCell>
						<TableCell leftBorderEnable="false" rightBorderEnable="false">
							<StringPropertyText propertyText="documentation"
								style="Table Contents" />
						</TableCell>
					</TableRow>

					<!-- Iterate thru the attributes -->
					<IterationBlock modelType="Attribute">
						<TableRow>
							<TableCell leftBorderEnable="false" rightBorderEnable="false">
								<StaticText content="Attribute " style="Table Contents" />
								<StringPropertyText propertyText="name"
									style="Table Contents" />
							</TableCell>
							<TableCell leftBorderEnable="false" rightBorderEnable="false">
								<StringPropertyText propertyText="documentation"
									style="Table Contents" />
							</TableCell>
						</TableRow>
					</IterationBlock>

			</TableBlock>
		</HasChildElementChecker>
		<StaticText content="" style="Default" />
	</DiagramBaseInitiationBlock>
</Template>

TIA.
Ion


#2

I have this same question. I believe one uses a ForEach and not an IterationBlock but I can’t find the attributes as “attribute”, “Attribute”, “attributes”, or “Attributes”.

Here’s what doesn’t work. It’s the ForEach that I think ought to work. The output is as desired for everything outside the ForEach. A nested InterationBlock with the modelType of “Attributes” and its variants similarly generates no results.

<?xml version="1.0" encoding="UTF-8"?>
<DiagramBaseInitiationBlock>
	<Property property="name" isBold="true"></Property>
	<ParagraphBreak></ParagraphBreak>
	<Image></Image>
	<ParagraphBreak/>

	<IterationBlock modelType="Class">
	<TableBlock>
	<TableRow>
	<TableCell><Text>Name: </Text></TableCell>
	<TableCell><Property property="name"/></TableCell>
	</TableRow>
	<TableRow>
	<TableCell><Text>Description: </Text></TableCell>
	<TableCell><Property property="description"/></TableCell>
	</TableRow>
	<ForEach property = "Attributes">
	<TableRow>
	<TableCell><Text>Attribute: </Text><Property property="name"></Property></TableCell>
	<TableCell><Property property="description"></Property></TableCell></TableRow>
	</ForEach>
</TableBlock>	

	<ParagraphBreak/>
	</IterationBlock>

</DiagramBaseInitiationBlock>