【发布时间】:2019-08-03 21:15:23
【问题描述】:
我有一个 SharePoint 列表,我需要为其创建一个自定义样式表。我无法从中获得任何输出。
Infopath 表单示例:
<xsl:for-each
select="xdXDocument:GetDOM("BusinessArea")/dfs:myFields/dfs:dataFields/d:SharePointListItem_RW">
<option>
<xsl:attribute name="value">
<xsl:value-of select="d:Title" />
</xsl:attribute>
<xsl:if test="$val=d:Title">
<xsl:attribute name="selected">selected</xsl:attribute>
</xsl:if>
<xsl:value-of select="d:Title" />
</option>
</xsl:for-each>
<td style="VERTICAL-ALIGN: middle; BORDER-LEFT-COLOR: ; PADDING-BOTTOM: 4px; PADDING-TOP: 4px"
class="xdTableMiddleCellEmphasis">
<span class="xdlabel"></span>
<span title="" class="xdTextBox xdBehavior_Formatting" hideFocus="1"
contentEditable="true" tabIndex="0" xd:boundProp="xd:num"
xd:binding="dfs:dataFields/my:SharePointListItem_RW/my:OPJan"
xd:CtrlId="CTRL1" xd:xctname="PlainText"
xd:datafmt=""number","numDigits:auto;negativeOrder:1;""
style="WIDTH: 100%">
<xsl:attribute name="xd:num">
<xsl:value-of select="dfs:dataFields/my:SharePointListItem_RW/my:OPJan" />
</xsl:attribute>
<xsl:choose>
<xsl:when test="function-available('xdFormatting:formatString')">
<xsl:value-of
select="xdFormatting:formatString(dfs:dataFields/my:SharePointListItem_RW/my:OPJan,"number","numDigits:auto;negativeOrder:1;")" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="dfs:dataFields/my:SharePointListItem_RW/my:OPJan" />
</xsl:otherwise>
</xsl:choose>
</span>
</td>
同样的 XSL:
<xsl:stylesheet version="1.0" xmlns:ma="http://schemas.microsoft.com/office/2009/metadata/properties/metaAttributes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dfs="http://schemas.microsoft.com/office/infopath/2003/dataFormSolution" xmlns:my="http://schemas.microsoft.com/office/infopath/2009/WSSList/cmeDataFields" xmlns:d="http://schemas.microsoft.com/office/infopath/2009/WSSList/dataFields" xmlns:pc="http://schemas.microsoft.com/office/infopath/2007/PartnerControls" xmlns:q="http://schemas.microsoft.com/office/infopath/2009/WSSList/queryFields" xmlns:dms="http://schemas.microsoft.com/office/2009/documentManagement/types" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:xdExtension="http://schemas.microsoft.com/office/infopath/2003/xslt/extension" xmlns:xdXDocument="http://schemas.microsoft.com/office/infopath/2003/xslt/xDocument" xmlns:xdSolution="http://schemas.microsoft.com/office/infopath/2003/xslt/solution" xmlns:xdFormatting="http://schemas.microsoft.com/office/infopath/2003/xslt/formatting" xmlns:xdImage="http://schemas.microsoft.com/office/infopath/2003/xslt/xImage" xmlns:xdUtil="http://schemas.microsoft.com/office/infopath/2003/xslt/Util" xmlns:xdMath="http://schemas.microsoft.com/office/infopath/2003/xslt/Math" xmlns:xdDate="http://schemas.microsoft.com/office/infopath/2003/xslt/Date" xmlns:sig="http://www.w3.org/2000/09/xmldsig#" xmlns:xdSignatureProperties="http://schemas.microsoft.com/office/infopath/2003/SignatureProperties" xmlns:ipApp="http://schemas.microsoft.com/office/infopath/2006/XPathExtension/ipApp" xmlns:xdEnvironment="http://schemas.microsoft.com/office/infopath/2006/xslt/environment" xmlns:xdUser="http://schemas.microsoft.com/office/infopath/2006/xslt/User" xmlns:xdServerInfo="http://schemas.microsoft.com/office/infopath/2009/xslt/ServerInfo">
<xsl:output method="html" encoding="utf-8" />
<xsl:template match="/">
<xsl:variable name="dvt_RowCount“ select=”count($Rows)" />
<html>
<body>
<h2>Test</h2>
<table border="1">
<tr>
<th>Title</th>
</tr>
<xsl:for-each
select="dfs:myFields/dfs:dataFields/my:SharePointListItem_RW">
<tr>
<td>
<xsl:value-of select="@my:Title" />
</td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
我有一个 Sharepoint 列表,我需要在其中为该列表创建自定义样式表。我需要遍历每个列表项并输出值。 目前我正在将标题作为输出。我无法获得任何价值。请帮助我获得输出。
【问题讨论】:
-
请注意,您的转换样本格式不正确。更正错误后它仍然抛出错误
Stylesheet compilation failed with 1 error(s): Error 1 at line 5:11 : Variable Rows has not been declared (or its declaration is not in scope) -
@Alejandro 同样来自自动创建的 Infopath 提取。我只需要xsl。如果有人需要更多信息,我只是分享了它。我使用下面的代码解决了它。感谢您的宝贵时间。
-
我告诉你,你的样式表有语法错误和语义错误(变量没有被声明)。这就是你没有得到输出的原因。
标签: xml xslt sharepoint-list