【问题标题】:XSL for SharePoint list no outputXSL for SharePoint 列表无输出
【发布时间】:2019-08-03 21:15:23
【问题描述】:

我有一个 SharePoint 列表,我需要为其创建一个自定义样式表。我无法从中获得任何输出。

Infopath 表单示例:

<xsl:for-each
select="xdXDocument:GetDOM(&quot;BusinessArea&quot;)/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="&quot;number&quot;,&quot;numDigits:auto;negativeOrder:1;&quot;"
    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,&quot;number&quot;,&quot;numDigits:auto;negativeOrder:1;&quot;)" />
        </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


【解决方案1】:

我找到了答案。这可能对其他人有帮助。

            <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:SharePoint="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

            <xsl:output method="html" indent="no"/>

            <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema">
            <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row" />
            <table border="1">
            <tr>
                <td>Title</td>
            </tr>

            <xsl:for-each select="$Rows">
            <xsl:call-template name="dvt_1.rowview" />
            </xsl:for-each>
            </table>
            </xsl:template>

            <xsl:template name="dvt_1.rowview">
            <tr>

                <td><xsl:value-of disable-output-escaping="yes" select="@Title"/></td>

            </tr>
            </xsl:template>
            </xsl:stylesheet>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-12-20
    • 2016-04-18
    • 1970-01-01
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 2013-08-14
    • 2021-01-27
    相关资源
    最近更新 更多