Subject: RE: [xsl] Total Missing documents for each Event From: Shashank Jain <shashankjain@xxxxxxxx> Date: Fri, 9 Apr 2010 10:17:25 -0500 |
Thanks David for that. Also I tried calculating the list of sp_document_type which are not in the sp_mand_doctypes. So my table should look like For 1st Event list of situational documents will be [--] and count is 0 For 2nd Event list of situational documents will be [--] and count is 0 For 3rd Event list of situational documents will be [Analyst] and count is 1. I was able to achieve what I want but was getting comma [,] at the end of every situational doc, I did that to tokenize the document array and to count them. Here my XML again <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> This is the XSLT I am using. <xsl:for-each select="event"> <xsl:call-template name="ExistSituational"/> </xsl:for-each> <xsl:template name="ExistSituational"> <xsl:param name="counter" /> <xsl:param name="docsType" /> <xsl:param name="mandatoryDocs" select="parent::node()/@sp_mand_doctypes"/> <xsl:param 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: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: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="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="NumMandExisting"> <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="existingDocs"> <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="docsArray" select="tokenize(normalize-space($existingDocs),',')"/> <xsl:choose> <xsl:when test="(count($docsArray) - 1) < 0"> <xsl:sequence select="0"/> </xsl:when> <xsl:otherwise> <xsl:sequence select="count($docsArray) - 1"/> </xsl:otherwise> </xsl:choose> </xsl:template> I tried the way you explained to calculate Missing documents in the previous post, but no luck. Thanks again, Shashank ---------------------------------------- > Date: Fri, 9 Apr 2010 01:33:49 +0100 > From: davidc@xxxxxxxxx > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > CC: shashankjain@xxxxxxxx > Subject: Re: [xsl] Total Missing documents for each Event~ > > On 08/04/2010 19:27, Shashank Jain wrote: >> >> Hello All, >> >> I am trying to create the list of missing documents and their count for each event. >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> >> 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. >> >> >> >> >> >> >> >> > .... > >> >> >> With this I am able to right number of Missing Docs f > > It's a syntax error to have an xsl:variable at this point, so i wouldn't > have expected this to run at all? > 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 > > separator=","/> > count > > select="count($x[not(.=current()/document_type/@sp_document_type)])"/> > _________________________________________________________________ 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=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Total Missing documents f, David Carlisle | Thread | Re: [xsl] Total Missing documents f, David Carlisle |
Re: [xsl] Ordered union of sequence, Michael Müller-Hille | Date | Re: [xsl] Total Missing documents f, David Carlisle |
Month |