[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Mandatory and Missing Columns

Subject: Re: Mandatory and Missing Columns
From: Wolfgang Laun <wolfgang.laun@xxxxxxxxx>
Date: Tue, 6 Apr 2010 09:37:14 +0200
Re:  Mandatory and Missing Columns
The main difficulty here is that you haven't provided a definition of
the composition of the list of mandatory document types in
@sp_mand_doctypes. Are the separators ", " or just "," or both? The
separators must be included in the contains test since at least one
document type is a substring of another one.

So, assuming just ", " as delimiter:

  <xsl:param name="sep" select="', '"/>

  <xsl:template match="/">

    <xsl:for-each select="//document_type[generate-id() =
generate-id(key('docType',@sp_document_type)[1])]">
      <xsl:variable name="doctype" select="@sp_document_type"/>
<tr>
      <xsl:variable name="events"

select="/data/event_template[contains(concat($sep,@sp_mand_doctypes,$sep),con
cat($sep,$doctype,$sep))]/event"/>
      <xsl:variable name="required" select="count($events)"/>
      <xsl:variable name="evreps"
select="count($events/document_type[@sp_document_type = $doctype])"/>

  <td><xsl:value-of select="@sp_document_type"/></td>
  <td><xsl:value-of select="$required"/></td>
  <td><xsl:value-of select="$required - $evreps"/></td>
</tr>
    </xsl:for-each>
  </xsl:template>

If "," does occur or just to be on the safe side, another contains()
test has to be added, enclosing $doctype in a pair of strings:
concat(",", $doctype, ",")

If you have XSLT 2.0, you can simply use:

 <xsl:variable name="events"
      select="/data/event_template[tokenize(@sp_mand_doctypes,'\s*,\s*')
= $doctype]/event"/>

-W

On Mon, Apr 5, 2010 at 11:58 PM, Shashank Jain <shashankjain@xxxxxxxx> wrote:
>
> 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.