Tuesday, November 18, 2008

Re: [sharepointdiscussions] Re:convert excel formula to xsl for use in data form web part

I'm not sure what the source xsl would be since it is pulling from a SharePoint list.  As far as the result. It's probably overly simple;  basically what I am trying to do is to show an average of requests closed per day.  I can get a total number of requests closed fairly easily and set that as a variable.  For each request in the list, there is a field that is automatically populated with the date that the request was closed.  If I were to group everything by date closed, I just need to count how many groups there are.  The only output I need from this is a number; how many dates are in the list.  (I will add that as a variable to use in the formula to calculate the average.)  Once I can get that number, I'm good. Hope that helps describe my issue in more detail.  And thank you all for your help.


________________________________
From: Rainer Wittmann <R.Wittmann@spirit.de>
To: "sharepointdiscussions@yahoogroups.com" <sharepointdiscussions@yahoogroups.com>
Sent: Tuesday, November 18, 2008 4:24:46 AM
Subject: RE: [sharepointdiscussions] Re:convert excel formula to xsl for use in data form web part


Yeap, there are some issues with your XSLT.

But before we go any further here's a rule of thumb. Whenever you need help with XSLT, please provide a) an example of the source XML, b) the XSLT (done below) and c) the desired output.

To accomplish a)
Save the following in a text file called XMLResults.xslt and link that to your web part using <XslLink>PathToXMLr esults.xslt< /XslLink>
This element should be used either before or after the <Xsl> element. You can use the web part properties miscellaneous section as well to configure this.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3. org/1999/ XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF- 8" indent="yes" />

<xsl:template match="/">
<xmp>
<xsl:copy-of select="*" />
</xmp>
</xsl:template>
</xsl:stylesheet>

When you open the page with the browser you should see something similar to the following:

<dsQueryResponse>
<Rows>
<Row Title="hello world" Priority="(2) Normal" Status="Not Started" ... more attributes />
</Rows>
</dsQueryResponse>

Note: One Row element is enough and please cut out attributes that are not required for the example.

Rainer

-----Original Message-----
From: sharepointdiscussio ns@yahoogroups. com [mailto:sharepointdiscussio ns@yahoogroups. com] On Behalf Of Jay Strickland
Sent: Montag, 17. November 2008 21:34
To: sharepointdiscussio ns@yahoogroups. com
Subject: Re: [sharepointdiscussi ons] Re:convert excel formula to xsl for use in data form web part

I tried the solution that you recommended, and the result that I get is not correct. I must have screwed something up somewhere in the code. All of which is pasted here for reference. Once I can get this value, I can plug it into a variable to use, but getting the initial value is proving the most difficult.

<WebPartPages: DataFormWebPart runat="server" __markuptype= "vsattributemark up" ViewFlag="9" ViewContentTypeId= "0x" DetailLink=" /HelpDesk/ Lists/Service Requests/My Active Service Requests.aspx" Width="" Height="" FrameState=" Normal" IsIncluded=" true" IsVisible="true" Dir="Default" AllowRemove= "true" AllowZoneChange= "true" AllowMinimize= "true" Description= "Use the Service Requests list to track detailed information and resolutions for service requests." MissingAssembly= "Cannot import this Web Part." PartImageSmall= "" PartImageLarge= "/_layouts/ images/ittask. gif" PartOrder="2" DisplayName= "" ListName="{091F2CA2 -D414-4DE2- B9B2-EB48448566B 3}" Title="Service Requests (1)" FrameType="Default" NoDefaultStyle= "TRUE" __WebPartId= "{724A9A85- A56C-41BA- A4E8-A498124C057 0}" id="g_724a9a85_ a56c_41ba_ a4e8_a498124c057 0" pagesize="100" >
<DataSources>
<SharePoint: SPDataSource runat="server" IncludeHidden= "true" SelectCommand= "&lt;View& gt;&lt;Query& gt;&lt;Where& gt;&#xA; &lt;Eq&gt;&# xA; &lt;FieldRef Name=&quot;Status& quot;/&gt; &#xA; &lt;Value Type=&quot;Text& quot;&gt; Closed&lt; /Value&gt; &#xA; &lt;/Eq&gt;& #xA; &lt;/Where&gt; &#xA; &lt;OrderBy& gt;&lt;FieldRef Name=&quot;DueDate& quot; Ascending=&quot; TRUE&quot; /&gt;&lt; /OrderBy& gt;&lt;GroupBy Collapse=&quot; TRUE&quot; &gt;&#xA; &lt;FieldRef Name=&quot;DueDate& quot;/&gt; &#xA; &lt;/GroupBy& gt;&#xA; &lt;/Query&gt; &lt;/View& gt;" id="datasource1" DataSourceMode= "List" UseInternalName= "true"><InsertPa rameters> <asp:Parameter DefaultValue= "{091F2CA2- D414-4DE2- B9B2-EB48448566B 3}" Name="ListID" ></asp:Parameter >
</InsertParameters> <UpdateParameter s><asp:Parameter DefaultValue= "{091F2CA2- D414-4DE2- B9B2-EB48448566B 3}" Name="ListID" ></asp:Parameter >
</UpdateParameters> <DeleteParameter s><asp:Parameter DefaultValue= "{091F2CA2- D414-4DE2- B9B2-EB48448566B 3}" Name="ListID" ></asp:Parameter >
</DeleteParameters> <SelectParameter s><asp:Parameter Name="ListID" DefaultValue= "{091F2CA2- D414-4DE2- B9B2-EB48448566B 3}"/><asp: QueryStringParam eter Name="RootFolder" querystringfield= "RootFolder" type="String" /><asp:Parameter Name="StartRowIndex " DefaultValue= "0"/><asp: Parameter Name="nextpagedata" DefaultValue= "0"/><asp: Parameter Name="MaximumRows" DefaultValue= "100"/></ SelectParameters >
</SharePoint: SPDataSource>
</DataSources>
<ParameterBindings>
<ParameterBinding Name="ListName" Location="None" DefaultValue= "Service Requests"/>
<ParameterBinding Name="Userid" Location="Postback; Connection; CAMLVariable" />
<ParameterBinding Name="UserID" Location="CAMLVaria ble" DefaultValue= "CurrentUserName "/>
<ParameterBinding Name="Today" Location="CAMLVaria ble" DefaultValue= "CurrentDate" />
</ParameterBindings >
<XSL>
<xsl:stylesheet version="1.0" exclude-result- prefixes= "rs z o s ddwrt dt msxsl" xmlns:msxsl= "urn:schemas- microsoft- com:xslt" xmlns:xsl="http://www.w3. org/1999/ XSL/Transform" xmlns:SharePoint= "Microsoft. SharePoint. WebControls" xmlns:__designer= "http://schemas. microsoft. com/WebParts/ v2/DataView/ designer" xmlns:asp="http://schemas. microsoft. com/ASPNET/ 20" xmlns:ddwrt= "http://schemas. microsoft. com/WebParts/ v2/DataView/ runtime" xmlns:o="urn: schemas-microsof t-com:office" xmlns:s="uuid: BDC6E3F0- 6DA3-11d1- A2A3-00AA00C1488 2" xmlns:dt="uuid: C2F41010- 65B3-11d1- A29F-00AA00C1488 2" xmlns:rs="urn: schemas-microsof t-com:rowset" xmlns:z="#RowsetSch ema" xmlns:ddwrt2= "urn:frontpage: internal" ><xsl:output method="html" indent="no" /><xsl:decimal- format NaN="" />
<xsl:param name="FilterLink" select="ddwrt: FilterLink( )" />
<xsl:param name="dvt_apos" >&apos;</ xsl:param>
<xsl:param name="filterParam" ddwrt:NoCAMLVariabl e="1"></xsl: param>
<xsl:param name="Userid" ></xsl:param>
<xsl:variable name="dvt_1_ automode" >0</xsl:variable >
<xsl:template match="/" xmlns:SharePoint= "Microsoft. SharePoint. WebControls" xmlns:__designer= "http://schemas. microsoft. com/WebParts/ v2/DataView/ designer" xmlns:asp="http://schemas. microsoft. com/ASPNET/ 20">
<xsl:call-template name="dvt_1" />
</xsl:template>
<xsl:key name="Rows-by- Date" match="Row" use="@DueDate" />
<xsl:template name="dvt_1" match="Row" mode="attr-group" >
<xsl:value-of select="@DueDate" />
<xsl:value-of select="count( key('Rows- by-Date', @DueDate))" />
<xsl:apply-template s mode="attr-group" select="Row[ generate- id(.)=generate- id(key('Rows- by-Date', @DueDate)[1] )]">
<xsl:sort select="@DueDate" />
</xsl:apply- templates>
</xsl:template>

</xsl:stylesheet>
</XSL>

<datafields> @Title,Service Request;@Details, Details;@ Customer, Customer; @Keywords, Keywords; @Priority, Priority; @Status,Status; @AssignedTo, Assigned To;@Comments, Comments; @DueDate, Resolution Date;@Resolution_ x0020_Time, Resolution Time;@StartDate, Start Date;@WorkflowLink, Link;@OffsitePar ticipant, External Participant; @OffsiteParticip antReason, External Participant Reason;@WorkflowOut come,Outcome; @ContentType, Content Type;@Resolution_ x0020_Type, Resolution Type;@Resolution_ x0020_Details, Resolution Details;@HelpDesk, Help Desk Notification; @Reminder, Reminders; @Workflow, Close Request;@ID, ID;@Modified, Modified; @Created, Created;@ Author,Created By;@Editor,Modified By;@_UIVersionStrin g,Version; @Attachments, Attachments; @File_x0020_ Type,File Type;@FileLeafRef, Name (for use in forms);@FileDirRef, Path;@FSObjType, Item Type;@_HasCopyDesti nations,Has Copy Destinations; @_CopySource, Copy Source;@ContentType Id,Content Type
ID;@_ModerationStat us,Approval Status;@_UIVersion, UI
Version;@Created_ x0020_Date, Created;@ FileRef,URL Path;
</datafields>
</WebPartPages: DataFormWebPart>

____________ _________ _________ __
From: Rainer Wittmann <R.Wittmann@spirit. de>
To: "sharepointdiscussio ns@yahoogroups. com" <sharepointdiscussio ns@yahoogroups. com>
Sent: Monday, November 17, 2008 12:17:42 PM
Subject: RE: [sharepointdiscussi ons] Re:convert excel formula to xsl for use in data form web part

No easy way at all, but still doable.

Look for Munchian group algorithm, best described by Jeni Tennison
http://www.jenitenn ison.com/ xslt/grouping/ index.html

In a nutshell:
You want to group and count an attribute @attribute which is part of an ROW element.

Step 1: Set up a key: <xsl:key name="Rows-by- attr" match="Row" use="@attribute" />

Step 2: Create a template with mode attr-group.

<xsl:template match="Row" mode="attr-group" >
<xsl:value-of select="@attribute" />
(<xsl:value- of select="count( key(' Rows-by-attr, @attribute)) " />)
</xsl:template>

Step 3: Wherever you are interested in the result apply the template from step 2:

<xsl:apply-template s mode="attr-group" select="Row[ generate- id(.) = generate-id( key(Rows- by-attr ', @attribute)[ 1])]"> <xsl:sort select="@attribute" />
</xsl:apply- templates>

Step 4: Find out what did go wrong when you implemented 1-3, which is the hardest part at all.

Good luck

Rainer

-----Original Message-----
From: sharepointdiscussio ns@yahoogroups. com [mailto:sharepointd iscussio ns@yahoogroups. com] On Behalf Of Jay Strickland
Sent: Montag, 17. November 2008 18:45
To: sharepointdiscussio ns@yahoogroups. com
Subject: Re: [sharepointdiscussi ons] Re:convert excel formula to xsl for use in data form web part

XSLT 2.0 supports the "distinct-values" operator, but SharePoint, or more specifically SPD, does not. I have been searching and so far the only answer I have seen is "counting is the same as sorting is the same as grouping." No, it really isn't. (None of the sample solutions are really helpful, and most don't work at all.) I would have thought that counting values but excluding repeat occurrences of the value would be failrly easy. Sadly I am mistaken. If anyone has any ideas on how to simply count how many entries are in a column, excluding duplicates, I would love to know.

____________ _________ _________ __
From: Dick Penny <d_penny@usa. net>
To: sharepointdiscussio ns@yahoogroups. com
Sent: Friday, November 14, 2008 3:33:22 PM
Subject: [sharepointdiscussi ons] Re:convert excel formula to xsl for use in data form web part

I don't have an exact answer, BUT, I've seen some XSLT recipes somewhere and
thought one of them was "counting distinct items." Try the W3..org site. Or
google "XSLT recipes".

Dick Penny

[Non-text portions of this message have been removed]

------------ --------- --------- ------

Yahoo! Groups Links

[Non-text portions of this message have been removed]

------------ --------- --------- ------

Yahoo! Groups Links


[Non-text portions of this message have been removed]


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/sharepointdiscussions/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/sharepointdiscussions/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:sharepointdiscussions-digest@yahoogroups.com
mailto:sharepointdiscussions-fullfeatured@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
sharepointdiscussions-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

0 comments: