English 中文(简体)
XSLT 采用SP清单的公式
原标题:XSLT equation using SP list fields

I have a SP Dataview that I have converted to XSLT, so that I could add a header displaying a percentage (Complete).
Before I converted the dvwp to xslt, I added two count headers- one on Complete, and another on LastName. They worked wonderfully- showing me the # of records and the # of records with a value in the complete field. However, when I converted the dv to xslt I realized that I lost my headers :(

So, I am adding them back in using xslt. Currently the XPath code for the equation that I have is <xsl:value-of select="count($Rows) div count($Rows)" />.
How do I get the total # of Yes values that are in my Complete field?

UPDATE1:
Found this http://www.endusersharepoint.com/STP/viewtopic.php?f=14&t=534 and tried it, however causes the following error- Failed setting processor stylesheet: 0x80004005: Argument 1 must return a node-set. -->count(/dsQueryResponse/Rows/Row= Y )<--

UPDATE2:
Complete is the name of a field w/i my XSLT dataset. The return type is either Y or blank. For grins I tried <xsl:value-of select="count(/xpath/to/parent/element[@Complete eq Y ]) div count($Rows)" /> however I recieved the following error- Failed setting processor stylesheet: 0x80004005: Expected token ] found NAME .count((/xpath/to/parent/element[@Complete -->eq <-- Y ]) div count($Rows) Am starting to think that there may be a problem w/ eq .... Referencing my XML operators...

UPDATE3:

<xsl:value-of select="count(/xpath/to/parent/element[@Complete =  Y ]) div count($Rows)" />

因此,“奥凯”仍然说零,但我认为,它为什么不展示正确的答案,是b)它期望显示一种愤怒,而且从这一公式中收回的价值显然会是一种弊端。 曾与我所尝试的那段话的XPath的公式相交

count(/xpath/to/parent/element[@Complete =  Y ]) div count($Rows)*100
(count(/xpath/to/parent/element[@Complete =  Y ]) div count($Rows))*100
100(count(/xpath/to/parent/element[@Complete =  Y ]) div count($Rows))

UPDATE4:
So I know my previous thought that the correct number not showing b/c it was a float is not correct, as all numbers in XPath and XSLT 1.0 are floats. Reference

UPDATE5:
Upon further investigation, I have found that the problem lies with the count(/xpath/to/parent/element[@Complete = Y ]) part of my equation, as this is returning 0 instead of a value. [i know i have at least 3 Y vals in my Complete col]

<>><>>>>>>>

<records*>
<record*>
  <last_name></last_name>
  <first_name></first_name>
  <mi></mi>
  <office_symbol></office_symbol>
  <geo_location></geo_location>
  <complete></complete>
  <date_complete></date_complete>
  <date_expires></date_expires>
  <email></email>
  <supervisor></supervior>
</record*>
</records*>

*i don t know what these nodes are called as my data is coming from a database and not an xml file, i just made up record/records

UPDATE7
Going back to my original question. I am still trying to find out the XPath equation to display the number of parents (record in the XML i posted above) where the complete node = Y.

UPDATE8
Ok. So I have edited and tested using http://www.w3schools.com/xsl/tryxslt.asp?xmlfile=cdcatalog&xsltfile=tryxsl_value-of. Working XSLT to count the # of Complete = Y is <xsl:value-of select="count(catalog/cd [complete = Y ])" /> so theen I put EXACTLY what works on W3schools into my SP Dataview and I get nothing... just an empty space. Why doesn t the code work in my SPDV?

最佳回答

If your "Complete" field is an element:

 <xsl:value-of select="count(/xpath/to/complete/field/element[string(.) eq  Yes])"/>

If your complete field is an attribute of an element:

 <xsl:value-of select="count(/xpath/to/parent/element[@complete eq  Yes ])"/>

Without knowing the structure of your XML I can t provide the specific XPATH required -- the predicate "[]" is what selects only the "Yes" values

问题回答

暂无回答




相关问题
SharePoint - Approaching Website Storage Limit Email

How can i go about changing the distribution list as well as the email text for the email that goes out to site collection admin when a site collection approaches it s size limit? Thanks for your ...

UI automated testing within SharePoint

I m looking for automated Functional Testing tools that can manipulate SharePoint sites, libraries, and documents thought the web interface. It needs to be extensible enough to handle any custom ...

Enable authorization on sitemap provider

I want to enable Authorization on the Site map provider. We have enabled anonymous access to the site and we want the Site map provider to be visible only to authorized users. I tried ...

SharePoint : web service permission error

I have a sharepoint site, and I am calling a standard sharepoint web service. I create the web service request like this : wsDws.Url = this.SiteAddress + @"/_vti_bin/Dws.asmx"; When I use ...

Sharepoint 2007 Data view Webpart custom parameters

I m sort of new to the custom parameters that can be setup on a DataView Webpart. There are 6 options: - None - Control - Cookie - Form - QueryString - Server Variable I think that None, Cookie and ...

热门标签