Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries >Thread Prev - stumped on XSL tranformation to produce normalized bar graph >Thread Next - Re: stumped on XSL tranformation to produce normalized bar graph Re: stumped on XSL tranformation to produce normalized bar graphTo: NULL Date: 6/23/2009 2:47:00 AM On Jun 22, 10:56=A0pm, Thomas V <tho...@badsoda.com> wrote:
> Hi,
>
> I'm new to XSL and have been given an assignment which has me stumed.
> I'm hoping you could assist. I've been given a set of XML data (see
> format below) and have been asked to produce a normalized bar grap in
> html for output.
>
> <xml>
> =A0 <rs:data>
> =A0 =A0<z:row class=3D'book' title=3D'nice book' status=3D'open' />
> =A0 =A0<z:row class=3D'book' title=3D'good book' status=3D'closed' />
> =A0 =A0<z:row class=3D'book' title=3D'aweful book' status=3D'closed' />
> =A0 =A0<z:row class=3D'vase' title=3D'blue vase' status=3D'open' />
> =A0 =A0<z:row class=3D'vase' title=3D'red vase' status=3D'closed' />
> =A0 =A0<z:row class=3D'vase' title=3D'green vase' status=3D'open' />
> =A0 </rs:data>
> </xml>
>
> The idea would be to have for each data row grouped per class and the
> relative number of statuses computed.
>
> Based on the above input the expected output would be as follows.
>
> <table>
> =A0 <tr><th>class</th><th span=3D2>graph</th></tr>
> =A0 <tr><td>book</th><td width=3D'33%'>open<td><td width=3D'67%'>closed<t=
d></
> tr>
> =A0 <tr><td>vase</th><td width=3D'33%'>open<td><td width=3D'67%'>closed<t=
d></
> tr>
> </table>
>
> It should be noted that the number of different values the status
> attribute can take can vary (ie. it can be more than just open an
> closed as in the example above).
>
> If you feel writing up XSL for this is trivial then your help would be
> greatly appreciated.
> - Thomas
Hi again,
I've made some progress on the issue grouping the items using the
Muenchian method. My xsl template now looks something like
<xsl:stylesheet
xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
xmlns:rs=3D'urn:schemas-microsoft-com:rowset'
xmlns:z=3D'#RowsetSchema'
version=3D"2.0">
<xsl:key name=3D"issues-class" match=3D"z:row" use=3D"@class" />
<xsl:template match=3D"rs:data">
<xsl:for-each select=3D"z:row[count(. | key('issues-class', @class)
[1]) =3D 1]">
<xsl:sort select=3D"@class" />
<xsl:value-of select=3D"substring-after(@class,'string;#')" />
<xsl:for-each select=3D"key('issues-class', @class)">
<xsl:sort select=3D"@title" />
<xsl:value-of select=3D"substring-after(@title,'string;#')" /
><xsl:value-of select=3D"@status" />
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
Now what I'd need to achieve is to:
- calculate how many records there are of each 'class' attribute
- for each 'class' calculate how many records there are of each
'status' attribute
- calculate the relative representation (percentage) each status
within a given class
With that I should be in a position to produce a table or a bar graph.
Again, if anyone out there can help it would be greatly appreciated.
-Thomas
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
