Subject: [xsl] Total Missing documents for each Event From: Shashank Jain <shashankjain@xxxxxxxx> Date: Thu, 8 Apr 2010 13:27:20 -0500 |
Hello All, I am trying to create the list of missing documents and their count for each event. <data> <event_template sp_mand_doctypes="PSC Minutes, Internal Approval, Rationale, Trade Instructions, IPS, Final Client Models"> <event> <document_type sp_document_type="Final Client Models"/> </event> <event> <document_type sp_document_type="Final Client Models"/> <document_type sp_document_type="Rationale"/> </event> <event> <document_type sp_document_type="Analyst"/> </event> <event_template> </data> So my table should look like For 1st Event list of missing documents will be [PSC Minutes, Internal Approval, Rationale, Trade Instructions, IPS] and count is 5 For 2nd Event list of missing documents will be [PSC Minutes, Internal Approval, Trade Instructions, IPS] and count is 4 For 3rd Event list of missing documents will be [PSC Minutes, Internal Approval, Rationale, Trade Instructions, IPS, Final Client Models] and count is 6. "Analyst" is not the mandatory document as it is not present in the sp_mand_doctype list. I am using this following code. <xsl:for-each select="event"> <xsl:call-template name =" DocsMissing "/> </xsl:for-each> <xsl:template name="DocsMissing"> <xsl:choose> <xsl:variable name="mandatoryDocs" select="parent::node()/@sp_mand_doctypes"/> <xsl:variable name="strArray" select="tokenize($mandatoryDocs,',')"/> <xsl:variable name="totalCount" select="count($strArray)"/> <xsl:variable name="existingDoc"> <xsl:for-each select="document_type"> <xsl:call-template name="matchDocs"> <xsl:with-param name="counter" select="$totalCount"/> <xsl:with-param name="docsType" select="@sp_document_type"/> <xsl:with-param name="strArray" select="$strArray"/> </xsl:call-template> </xsl:for-each> </xsl:variable> <xsl:variable name="situationalDoc"> <xsl:for-each select="document_type"> <xsl:call-template name="SituationalDocs"> <xsl:with-param name="docsType" select="@sp_document_type"/> <xsl:with-param name="existingDoc" select="$existingDoc"/> </xsl:call-template> </xsl:for-each> </xsl:variable> <xsl:for-each select="document_type"> <xsl:call-template name="MissingDoc"> <xsl:with-param name="counter" select="$totalCount"/> <xsl:with-param name="docsType" select="@sp_document_type"/> <xsl:with-param name="strArray" select="$strArray"/> <xsl:with-param name="existingDoc" select="$existingDoc"/> <xsl:with-param name="situationalDoc" select="$situationalDoc"/> </xsl:call-template> </xsl:for-each> </xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="matchDocs"> <xsl:param name="counter"/> <xsl:param name="docsType"/> <xsl:param name="strArray"/> <xsl:choose> <xsl:when test="normalize-space($strArray[$counter])=$docsType"> <xsl:value-of select="$docsType"/>, </xsl:when> </xsl:choose> <xsl:if test="$counter> 0"> <xsl:call-template name="matchDocs"> <xsl:with-param name="counter" select="$counter - 1"/> <xsl:with-param name="docsType" select="$docsType"/> <xsl:with-param name="strArray" select="$strArray"/> </xsl:call-template> </xsl:if> </xsl:template> <xsl:template name="SituationalDocs"> <xsl:param name="docsType"/> <xsl:param name="existingDoc"/> <xsl:if test="not(contains($existingDoc, $docsType))"> <xsl:value-of select="$docsType"/>, </xsl:if> </xsl:template> <xsl:template name="MissingDoc"> <xsl:param name="counter"/> <xsl:param name="docsType"/> <xsl:param name="strArray"/> <xsl:param name="existingDoc"/> <xsl:param name="situationalDoc"/> <xsl:if test="not(contains($situationalDoc, $docsType)) and not(contains($existingDoc, $strArray[$counter]))"> <xsl:choose> <xsl:when test="normalize-space($strArray[$counter])!=$docsType"> <xsl:value-of select="$strArray[$counter]"/>, </xsl:when> </xsl:choose> </xsl:if> <xsl:if test="$counter>=1"> <xsl:choose> <xsl:when test="normalize-space($strArray[$counter])!=$docsType"> <xsl:call-template name="MissingDoc"> <xsl:with-param name="counter" select="$counter - 1"/> <xsl:with-param name="docsType" select="$docsType"/> <xsl:with-param name="strArray" select="$strArray"/> <xsl:with-param name="existingDoc" select="$existingDoc"/> <xsl:with-param name="situationalDoc" select="$situationalDoc"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="MissingDoc"> <xsl:with-param name="counter" select="$counter - 1"/> <xsl:with-param name="docsType" select="$docsType"/> <xsl:with-param name="strArray" select="$strArray"/> <xsl:with-param name="existingDoc" select="$existingDoc"/> <xsl:with-param name="situationalDoc" select="$situationalDoc"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:if> </xsl:template> With this I am able to right number of Missing Docs for Event 1 and 3 but for Event 2 its adding missing documents for each document type so I am getting (5+5) 10. Please correct me where I am doing wrong, or is there any other simple way. Thanks, Shashank Jain _________________________________________________________________ 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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Ordered union of sequence, Michael Kay | Thread | Re: [xsl] Total Missing documents f, David Carlisle |
Re: [xsl] Grouping problem, Martin Honnen | Date | RE: [xsl] Grouping problem, Joel Dubien |
Month |