xsl-list
[Top] [All Lists]

RE: [xsl] Total Missing documents for each Event‏

2010-04-26 11:51:46


<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;
        mso-font-charset:1;
        mso-generic-font-family:roman;
        mso-font-format:other;
        mso-font-pitch:variable;
        mso-font-signature:0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;
        mso-font-charset:0;
        mso-generic-font-family:swiss;
        mso-font-pitch:variable;
        mso-font-signature:-1610611985 1073750139 0 0 159 0;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;
        mso-font-charset:0;
        mso-generic-font-family:modern;
        mso-font-pitch:fixed;
        mso-font-signature:-1610611985 1073750091 0 0 159 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-unhide:no;
        mso-style-qformat:yes;
        mso-style-parent:"";
        margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-ascii-font-family:Calibri;
        mso-ascii-theme-font:minor-latin;
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-hansi-font-family:Calibri;
        mso-hansi-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;}
p.MsoPlainText, li.MsoPlainText, div.MsoPlainText
        {mso-style-noshow:yes;
        mso-style-priority:99;
        mso-style-link:"Plain Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        mso-pagination:widow-orphan;
        font-size:10.5pt;
        font-family:Consolas;
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;}
span.EmailStyle15
        {mso-style-type:personal;
        mso-style-noshow:yes;
        mso-style-unhide:no;
        mso-ansi-font-size:11.0pt;
        mso-bidi-font-size:11.0pt;
        font-family:"Calibri","sans-serif";
        mso-ascii-font-family:Calibri;
        mso-ascii-theme-font:minor-latin;
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-hansi-font-family:Calibri;
        mso-hansi-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;
        color:windowtext;}
span.PlainTextChar
        {mso-style-name:"Plain Text Char";
        mso-style-noshow:yes;
        mso-style-priority:99;
        mso-style-unhide:no;
        mso-style-locked:yes;
        mso-style-link:"Plain Text";
        mso-ansi-font-size:10.5pt;
        mso-bidi-font-size:10.5pt;
        font-family:Consolas;
        mso-ascii-font-family:Consolas;
        mso-hansi-font-family:Consolas;}
.MsoChpDefault
        {mso-style-type:export-only;
        mso-default-props:yes;
        mso-ascii-font-family:Calibri;
        mso-ascii-theme-font:minor-latin;
        mso-fareast-font-family:Calibri;
        mso-fareast-theme-font:minor-latin;
        mso-hansi-font-family:Calibri;
        mso-hansi-theme-font:minor-latin;
        mso-bidi-font-family:"Times New Roman";
        mso-bidi-theme-font:minor-bidi;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;
        mso-header-margin:.5in;
        mso-footer-margin:.5in;
        mso-paper-source:0;}
div.Section1
        {page:Section1;}
-->


Hello All,

 

I am trying to calculate the Sum of total Missing Docs.

Here is my XML:

 

<data>

<event_template sp_mand_doctypes="PSC Minutes,
Internal Approval, Rationale, Trade Instructions, IPS, Final Client
Models">

<event complete="N">

   
<document_type sp_document_type="Final Client Models"/>

</event>

<event complete="N">

   
<document_type sp_document_type="Final Client Models"/>

   
<document_type sp_document_type="Rationale"/>

</event>

<event complete="N">

   
<document_type sp_document_type="Analyst"/>

</event>

</event_template>

<event_template sp_mand_doctypes="PSC Minutes, Rationale,
IPS, Final Client Models">

<event complete="N">

   
<document_type sp_document_type="Final Client Models"/>

</event>

<event complete="N">

   
<document_type sp_document_type="Final Client Models"/>

   
<document_type sp_document_type="Rationale"/>

</event>

</event_template>

</data>

 

Previously I used following template to calculate number
of missing events, thanks to David for that.

<xsl:template name="eventTemplate">

            <xsl:for-each
select="event">

                  <xsl:call-template
name="NumDocumentsMissing"/>

            </xsl:for-each>

</xsl:template>

 

<xsl:template name="NumDocumentsMissing">

      <xsl:choose>

            <xsl:when
test="@complete='Y'">

                  <xsl:text>--</xsl:text>

            </xsl:when>

      <xsl:otherwise>

            <xsl:variable
name="x"
select="tokenize(parent::node()/@sp_mand_doctypes,'\s*,\s*')"/>

                  <xsl:value-of
select="count($x[not(.=current()/document_type/@sp_document_type)])"/>

            </xsl:otherwise>

      </xsl:choose>

</xsl:template>

 

I got the required output 5,4,6,3,2.

 

Now I am trying to add all those values and for that I am
using this function, so I want the total to be 5+4+6+3+2=20

<xsl:function name="fns:totalMissing">

      <xsl:param
name="event" as="element()"/>

      <xsl:choose>

            <xsl:when
test="$event/@complete='Y'">

                  <xsl:sequence
select="0"/>

            </xsl:when>

            <xsl:otherwise>

                  <xsl:variable name="x"
select="tokenize($event/../@sp_mand_doctypes,'\s*,\s*')"/>

                  <xsl:sequence
select="count($x[not($event/document_type/@sp_document_type)])"/>

            </xsl:otherwise>

      </xsl:choose>

</xsl:function>

 

And calling this function in this way

<xsl:sequence select="sum(//event/fns:totalMissing(.))"/>

 

I am not able to get the desired output. Looks like
Function is not calculating the value at each event properly. Please correct me
where I am doing it wrong.

 

Thanks

Shashank

 



From: shashankjain(_at_)live(_dot_)com
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
CC: davidc(_at_)nag(_dot_)co(_dot_)uk
Date: Fri, 9 Apr 2010 11:35:27 -0500
Subject: RE: [xsl] Total Missing documents for each Event‏


Thanks David !

You understood my requirement very well, this is exactly what I wanted.
I agree my code is vastly complicated , I will work on it to write more 
efficient code.

Thanks again.

Shashank

----------------------------------------
Date: Fri, 9 Apr 2010 17:00:02 +0100
From: davidc(_at_)nag(_dot_)co(_dot_)uk
To: shashankjain(_at_)live(_dot_)com
CC: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: Re: [xsl] Total Missing documents for each Event‏

Either I'm not understanding your requirements or your code is vastly
more complicated than needed (or both)

i think you just want


xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>




select="tokenize(@sp_mand_doctypes,'\s*,\s*')"/>

For event 
list is: 
select="$x[not(.=current()/document_type/@sp_document_type)]"
separator=","/>
 count 

select="count($x[not(.=current()/document_type/@sp_document_type)])"/>
additional docs: 
select="document_type/@sp_document_type[not(.=$x)]"
separator=","/>
 count 






which makes


$ saxon9 list.xml list.xsl


For event 1
list is: PSC Minutes,Internal Approval,Rationale,Trade
Instructions,IPS count 5
additional docs: count 0
For event 2
list is: PSC Minutes,Internal Approval,Trade Instructions,IPS count 4
additional docs: count 0
For event 3
list is: PSC Minutes,Internal Approval,Rationale,Trade
Instructions,IPS,Final Client Models count 6
additional docs: Analyst count 1





________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs.
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
--~--

                                        
_________________________________________________________________
The New Busy is not the too busy. Combine all your e-mail accounts with 
Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multiaccount&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_4

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

                                          
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--