[xsl] Mandatory and Missing Columns

Subject: [xsl] Mandatory and Missing Columns
From: Shashank Jain <shashankjain@xxxxxxxx>
Date: Mon, 5 Apr 2010 16:58:18 -0500
Hello All,

I am trying to create a table which has 3 columns like

Stock Report  6  3



Report        0  0



EPS Model     7  5



Articles      0  0

DCF Model     4  3

first column list all the sp_document_types. Second Column list the total # of
events in which the document type is mandatory and the third column list total
number of events in which sp_document_type is missing.

Here is my XML

<data business_group_id="is_er">
   <event_template  sp_mand_doctypes="Research Note, Prior Stock Report -
Edited / Reviewed, Stock Report">
      <event complete="N" />
      <event complete="N">
         <document_type complete="Y" sp_document_type="Stock Report"/>
         <document_type complete="Y" sp_document_type="Report"/>
      </event>
      <event complete="N">
        <document_type complete="Y"
sp_document_type="Stock Report"/>
      </event>
   </event_template>

   <event_template  sp_mand_doctypes="EPS Model,Stock Report">
      <event
complete="N" />
      <event complete="N">
         <document_type complete="Y" sp_document_type="EPS Model"/>
     
</event>

      <event complete="N">

        <document_type complete="Y"
sp_document_type="Stock Report"/>

      </event>

   </event_template>

   <event_template  sp_mand_doctypes="DCF Model, EPS Model">

      <event
complete="N" />

      <event complete="N">

        
<document_type complete="Y" sp_document_type="Articles"/>

        
 <document_type complete="Y" sp_document_type="EPS Model"/>

     
</event>


      <event complete="N">


        <document_type complete="Y"
sp_document_type="Stock Report"/>


      </event>
      <event complete="N">


        
<document_type complete="Y" sp_document_type="Articles"/>


        
 <document_type complete="Y" sp_document_type="DCF Model"/>


     
</event>


   </event_template>
</data>

First column list all the sp_document_types
Stock Report
Report
EPS Model
Articles
DCF Model

For this I created one key function
<xsl:key name="docType" match="document_type" use="@sp_document_type"/>

and used it like this

<xsl:for-each select="//document_type[generate-id() =
generate-id(key('docType',@sp_document_type)[1])]">
<tr>
<td>
   <xsl:value-of select="@sp_document_type"/>
</td>
<tr>
</xsl:for-each>

I was able to achieve the first column.

In the second column I want in how many events sp_document_type is required.
It means if we look at the first 'event_template' it has 3 mandatory documents
(Research Note, Prior Stock Report - Edited / Reviewed, Stock Report) which
should be present in the every 'event' child of event_template. But "Stock
report" is present in only 2 'events' of that 'event_template'.
Similarly second event_template has 2mandatory documents "EPS Model" and
"Stock report" and both the documents are present in one event but they were
required in all the events.
So my table will look some thing like

Stock Report  3+3+0 (since Stock report is not required in 3rd
event_template)

Report        0+0+0   (It is not required in any of the event_template)

EPS Model     0+3+4

Articles      0+0+0
DCF Model     0+0+4

In the thrid column I am trying to list total number of events in which
'sp_document_type' is missing.
It means, if we again look at the first event_template 'Stock Report' is one
of the mandatory document but it is missing in one of the event of
event_template. Similarly Stock Report is missing from the 2 of the events of
the second event_template.
Stock Report  1+2+0


Report        0+0+0  


EPS Model     0+2+3


Articles      0+0+0
DCF Model     0+0+3

I will appreciate if somebody can advice me in figuring out other two columns.

Thanks
Shashank Jain



_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with
Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID283
26::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5

Current Thread